-
In VSCode open your command palette —
Ctrl+Shift+Pby default -
Look for
Python: Select Interpreter -
In
Select InterpreterchooseEnter interpreter path...and thenFind... -
Navigate to your
venvfolder — eg,~/pyenvs/myenv/or\Users\Foo\Bar\PyEnvs\MyEnv\ -
In the virtual environment folder choose
<your-venv-name>/bin/pythonor<your-venv-name>/bin/python3
The issue is that VSCode’s Python extension by default uses the main python or python3 program while venv effectively creates a “new” python/python3 executable (that is kind of the point of venv) so the extension does not have access to anything (available modules, namespaces, etc) that you have installed through a venv since the venv specific installations are not available to the main Python interpreter (again, this is by design—like how applications installed in a VM are not available to the host OS)