Reputation: 2411
I'm using Python's venv
and am unsure how to get VS Code to recognise the folder layout.
The interpreter is the system-level Python, so it doesn't see the project's Lib/
, Scripts/
, Include/
, etc. and thus fails to find (import) the modules I've already added.
Is there a way to configure VS Code to work with venv
projects and non-venv
ones, or do I have to set python.pythonPath
per-project?
Upvotes: 2
Views: 374
Reputation: 378
Open a folder in the level above your venv directory. Then VS Code will discover the python.exe that lives inside /Scripts.
For example, if you created your venv in C:\MyProjects
C:\MyProjects> python -m venv MyEnv
Then in VS Code,
Open Folder... (Ctrl-K Ctrl-O)
Select C:\MyProjects
Command Palette... (Ctrl-Shift-P)
Python: Select Interpreter<Enter>
You should now see a dropdown list that includes .\MyEnv\Scripts\python.exe.
https://github.com/Microsoft/vscode-python/issues/2470#issuecomment-418459133
Upvotes: 1