Python Unresolved import issue
When pylinting a file in a big project, it appears as though libraries installed in a venv are not being discovered and thus I'm getting unresolved import issues.
Version: Visual Studio Code Version 1.33.0 Python 2.7.14 (which is what I have to use in my venv)
Sadly, I can't post a screen shot of the issues due to proprietary restrictions. However, I am able to tab over to the Terminal window, which is pointed to my venv and open python and import each of the libraries that the Problems view indicates are problems from the linting operation without issues.
These aren't pylint errors either they are "Python(unresolved-import)" issues. Neither pytlint, pep8, or flake8 report issues with those imports.
Seems similar to https://github.com/Microsoft/vscode-python/issues/3840 which was flagged as being closed, but doesn't appear to be resolved, and I can't post there as that issue is locked.
Could also be simlar to https://github.com/Microsoft/python-language-server/issues/541 which is 'closed' and https://github.com/Microsoft/python-language-server/issues/887 which made me spawn this issue.
I'll see if I can reproduce in more a basic way without proprietary libraries in the venv so that it can be fixed and add here with the details.
The entire thing, but for now I'm more concerned about what those weird \python \python\pyspark paths are. And are those logs without any extraPath configuration? ./core in that list should be making it show up in user search paths.
I haven't yet had time to look at your case yet (filing other issues and making sure 0.3 is okay to go live), but will be doing so next.
I definitely have ./core in my extraPaths. Here are the last few lines of my settings file. Is that all set up right?
"python.jediEnabled": false,
"python.autoComplete.extraPaths": [
"./core",
],
"python.analysis.downloadChannel": "daily",
"python.analysis.logLevel": "Trace",
As far as the \python and \python\pyspark paths... I'm not sure what those are either?
You have that in your global user settings, or the workspace settings? The other three are fine in the user settings, but since ./core is a project-specific thing, I'd expect that to be in .vscode/settings.json.
@jakebailey - Moving that to the workspace settings seems to have cleared everything up! I honestly didn't realize there were separate settings.... :man_facepalming:
Thank you! You're my hero!
This issue has been stale for more than a month; I'm going to close it.
If you're still having unresolved import issues, please check the docs here to see if extraPaths or PYTHONPATH are enough for you: https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings
If you're still having issues after trying that, please open a new issue with your case so we can look at it individually. We know there is still more work to be done when it comes to our import system (#443, #1360, others), but it's difficult to handle the varying cases all in one place.
Thanks!
+1
@jakebailey The issue has always been with me...

Please file a new issue. This issue is 9 months old and was about unresolved imports in user code; requests is a third party library.
I'm going through this and related issues, and for the most part you can fix things by setting
extraPathsto tell us more directories to use as import roots, for example:{ "python.autoComplete.extraPaths": [ "./src" ] }If you have more folders, you can list them all, and things should work.
However, this doesn't seem to work when a package gets installed as editable. I believe this has something to do with how the interpreter's own default search paths get modified and how we merge all of this configuration together. I'm currently just going through all of the test projects everyone has provided to get a good view on the unresolved imports first before trying to nail that one.
This did exactly solve the problem I was facing.
Multiple repos including python-files and vscode got somehow confused. Python-wise (debugging and such) it was working and vscode was able to follow my breakpoint. But my linter (flake8) was complaining about unresolved imports and I could not follow "Go To Definition F12" ...
After introducing this extraPaths it works like charm! :)
Thx!