The Python Oracle

Pylint "unresolved import" error in Visual Studio Code

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping

--

Chapters
00:00 Pylint &Quot;Unresolved Import&Quot; Error In Visual Studio Code
01:19 Accepted Answer Score 190
01:31 Answer 2 Score 58
01:58 Answer 3 Score 45
02:10 Answer 4 Score 171
02:27 Thank you

--

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

--

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