microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
913 stars 133 forks source link

"Unresolved import" for some files in sub-directories in a workspace #1223

Closed xobs closed 4 years ago

xobs commented 5 years ago

Opening a new issue as recommended from https://github.com/microsoft/python-language-server/issues/1099#issuecomment-503638516

Some Python packages are not able to be read by the Python Language Server. They report "unresolved import", despite the fact that Python is able to read them just fine.

The repository in question is https://github.com/xobs/teardown2019-workshop. It contains submodules, which either get added to a .env file (via python3 lxbuildenv.py > .env) or by manually adding them to the python.autoComplete.extraPaths setting.

python3 is able to see litex_boards.partner.platforms.fomu_evt, however the Python Language Server cannot.

This is running in python.org python3.exe version 3.7.3. There is no virtualenv, venv, conda, pip modules, or anything like that.

The language server version is Microsoft Python Language Server version 0.2.96.0

The line that is giving the error is https://github.com/xobs/teardown2019-workshop/blob/master/workshop.py#L28

An example of the "extraPaths" setting that didn't work is at https://github.com/xobs/teardown2019-workshop/blob/master/workshop.py#L10

xobs commented 5 years ago

Here is the result of the "trace". python-output.txt

Interestingly, "litex_boards" only appears in the list of search paths, and doesn't appear anywhere else.

jakebailey commented 5 years ago

Can you give the trace when on the daily build? Should be 0.3.16 at the moment. I changed the way that the search paths are printed to better reflect what we actually use.

xobs commented 5 years ago

Do you mean the daily python-language-server build? This is running on the daily vscode build:

Version: 1.35.1 (system setup)
Commit: c7d83e57cd18f18026a8162d042843bda1bcf21f
Date: 2019-06-12T14:30:02.622Z
Electron: 3.1.8
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17134

How can I install the daily pls build?

jakebailey commented 5 years ago

Sorry, I meant the language server daily, not VS Code or the extension. Set:

"python.analysis.downloadChannel": "daily"

And reload to trigger a download. Don't worry if it complains about the option not existing.

xobs commented 5 years ago

Here is the output from the daily python language server: python-output-daily.txt

jakebailey commented 5 years ago

Great, thanks. Just wanted to make sure that litex_boards was making it into the user search path list. I'll look at the repo and see what's going on.

jakebailey commented 4 years ago

Following up on this. Cloned the repo via:

git clone --recurse-submodules https://github.com/xobs/teardown2019-workshop.git

Then did:

python .\litex\lxbuildenv.py -e

To grab a PYTHONPATH line to put in .env, then loaded workshop.py. The only import that appears to be unresolved is lxbuildenv, which would require also adding ./litex to extraPaths or similar, which may then involve #443/#1360/#1700's nesting/naming problems.

image

Is this better than what you had observed?

jakebailey commented 4 years ago

Without feedback I'm going to close this; I think this was mostly handled except for the above linked issues to do with the single-name problem.