The Python Oracle

Pylint "unresolved import" error in Visual Studio Code

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Darkness Approaches Looping

--

Chapters
00:00 Question
01:23 Accepted answer (Score 176)
01:39 Answer 2 (Score 324)
02:03 Answer 3 (Score 137)
02:33 Answer 4 (Score 57)
03:12 Thank you

--

Full question
https://stackoverflow.com/questions/5393...

Question links:
[macOS v10.14]: https://en.wikipedia.org/wiki/MacOS_Moja...

Accepted answer links:
[workspace settings]: https://code.visualstudio.com/docs/getst...

Answer 2 links:
[Troubleshooting, Unresolved import warnings]: https://github.com/microsoft/python-lang...

Answer 3 links:
[image]: https://i.stack.imgur.com/XQEku.gif

Answer 4 links:
[Python unresolved import issue #3840]: https://github.com/Microsoft/vscode-pyth...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #django #visualstudiocode #pylint

#avk47



ACCEPTED ANSWER

Score 190


In your workspace settings, you can set your Python path like this:

{
    "python.defaultInterpreterPath": "/path/to/your/venv/bin/python",
}



ANSWER 2

Score 171


Alternative way: use the command interface!

Cmd/Ctrl + Shift + PPython: Select Interpreter → choose the one with the packages you look for:

Enter image description here




ANSWER 3

Score 58


This issue has already been opened on GitHub:

Python unresolved import issue #3840

There are two very useful answers, by MagnuesBrzenk and SpenHouet.

The best solution for now is to create a .env file in your project root folder. Then add a PYTHONPATH to it like this:

PYTHONPATH=YOUR/MODULES/PATH

And in your settings.json add:

"python.envFile": ".env"



ANSWER 4

Score 45


When I do > reload window that fixes it.

Reference: Python unresolved import issue #3840, dkavraal's comment