You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 4, 2024. It is now read-only.
Fix editable installs when using extraPaths/PYTHONPATH (microsoft#1183)
* Allow interpreter paths to be reclassified as user code if specified in user search paths
* log raw search path results only in verbose mode
* update TROUBLESHOOTING
Copy file name to clipboardExpand all lines: TROUBLESHOOTING.md
+41-5Lines changed: 41 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,10 @@ in [Filing an issue](#filing-an-issue).
9
9
10
10
There are a few known issues in the current version of the language server:
11
11
12
-
- Import statement handling may be too strict, leading to "unresolved import" messages and the lack of analysis.
13
-
- The language server considers the workspace root to be the root of user code imports. For the most part, this can be modified by adding additional folders to the `python.autoComplete.extraPaths` setting, for example, `"python.autoComplete.extraPaths": ["./src"]`, if `src` contains the user code. A `.env` file with `PYTHONPATH` set may also help.
14
-
- Editable installs (`pip install -e` or `setup.py develop`) are known not to work with `extraPaths` when the package is installed. (#1139, #1013, #1137, #989, others).
15
12
- Not all `__all__` statements can be handled.
16
13
- Some modules may have an incorrect list of exported names.
17
14
See [#620](https://github.com/Microsoft/python-language-server/issues/620),
- Persistent issues with high memory consumption for users.
20
-
- In some contexts, users are experiencing higher than average amounts of memory being consumed. See [#832](https://github.com/Microsoft/python-language-server/issues/832).
21
16
22
17
23
18
## Requirements
@@ -38,6 +33,47 @@ but may require outside libraries such as OpenSSL 1.0 or `libicu` on Linux.
38
33
39
34
## Common questions and issues
40
35
36
+
### Unresolved import warnings
37
+
38
+
If you're getting a warning about an unresolved import, first ensure that the
39
+
package is installed into your environment if it is a library (`pip`, `pipenv`, etc).
40
+
If the warning is about importing _your own_ code (and not a library), continue reading.
41
+
42
+
The language server treats the workspace root (i.e. folder you have opened) as
43
+
the main root of user module imports. This means that if your imports are not relative
44
+
to this path, the language server will not be able to find them. This is common
45
+
for users who have a `src` directory which contains their code, a directory for
46
+
an installable package, etc.
47
+
48
+
These extra roots must be specified to the language server. The easiest way to
49
+
do this (with the VS Code Python extension) is to create a workspace configuration
50
+
which sets `python.autoComplete.extraPaths`. For example, if a project uses a
51
+
`src` directory, then create a file `.vscode/settings.json` in the workspace
52
+
with the contents:
53
+
54
+
55
+
```json
56
+
{
57
+
"python.autoComplete.extraPaths": ["./src"]
58
+
}
59
+
```
60
+
61
+
This list can be extended to other paths within the workspace (or even with
62
+
code outside the workspace in more complicated setups). Relative paths will
63
+
be taken as relative to the workspace root.
64
+
65
+
This list may also be configured using the `PYTHONPATH` environment variable,
66
+
either set directly, or via a `.env` file in the workspace root (if using the
0 commit comments