Venv not working when in a sub directory
See original GitHub issueEnvironment data
- VS Code version: 1.50.1
- Extension version (available under the Extensions sidebar): v2020.10.332292344
- OS and version:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
- Python version (& distribution if applicable, e.g. Anaconda): 3.8 in venv
- Type of virtual environment used (N/A | venv | virtualenv | conda | …):
venv
- Relevant/affected Python packages and their versions: XXX
- Relevant/affected Python-related VS Code extensions and their versions: XXX
- Value of the
python.languageServer
setting: jedi
[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'
), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]
Expected behaviour
I expect the python binary inside dev/venv
to be used
Actual behaviour
The default interpreter is always selected
Steps to reproduce:
- Create
dev/
folder - Create
venv/
indev/
- Try to use the python interpreter in VSCode from
dev/venv/bin/python
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Why does VSCode not detect venv if the venv folder is ...
Sorry, I test it locally, but it can detect the subfolder virtual environment. If it still does not work, you can set python....
Read more >venv — Creation of virtual environments
Running this command creates the target directory (creating any parent directories that don't exist already) and places a pyvenv.cfg file in it with...
Read more >How To Set Up a Virtual Python Environment (Windows)
If Windows cannot find virtualenv.exe , see Install virtualenv. You can either add the executable's home directory to your PATH variable, or just...
Read more >Python and Virtual Environments - CS Guide
A Python virtual environment (venv) is simply a directory with a particular file structure. It has a bin subdirectory that includes links to ......
Read more >Python Virtual Environments: A Primer
In this tutorial, you'll learn how to work with Python's venv module to create ... management issues with tools like Pip, PyPI, Virtualenv, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried to type it, the default interpreter is used instead…
I also cannot change my interpreter any more. It doesn’t matter which one I select (all different conda environments), it always just stays with the one that it defaults to on startup of VSC.
I have tried reinstalling the extensions and deleting their files from
\.vscode\extensions\
, but to no avail. The problem should not be related to jedi or pylance as it persists even when none of them are enabled or installed. It is a pretty jarring problem as there seems to be no way to use python in VSC for the moment, safe for changing the one environment I can use every time I want to do something different.If I use
conda activate other-environment
it will show the (other-environment) in the terminal, but it won’t actually use that environment. At least that is what it looks like because imports from other-environment clearly aren’t working.Edit: “Enter interpreter path…” and selecting the environment manually does not solve the problem. VSC just ignores that the same way it ignores selections from the list.
Edit2: Okay, this is a surprise. There was a doubled pythonpath line in one of the settings files and switching the environments would only change the first occurence, not the second, thus getting stuck in the one environment. That seems like unintended behavior but would be a different issue altogether.