P.S.:
-
I have been using Visual Studio Code for a while now and found an another way to show virtual environments in Visual Studio Code.
-
Go to the parent folder in which
venv
is there through a command prompt. -
Type
code .
and Enter. [It is working on both Windows and Linux for me.] -
That should also show the virtual environments present in that folder.
Original Answer
I almost run into same problem every time I am working on Visual Studio Code using venv. I follow the below steps:
-
Go to menu File → Preferences → Settings.
-
Click on Workspace settings.
-
Under Files:Association, in the JSON: Schemas section, you will find Edit in settings.json. Click on that.
-
Update
"python.pythonPath": "Your_venv_path/bin/python"
under workspace settings.
(For Windows): Update"python.pythonPath": "Your_venv_path/Scripts/python.exe"
under workspace settings. -
Restart Visual Studio Code in case if it still doesn’t show your venv.
Note: Use python.defaultInterpreterPath
instead of python.pythonPath
for newer versions.