vscode-python: Venv not working when in a sub directory
Environment 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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 15 (4 by maintainers)
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.
In the meantime, what happens if you click on “Enter interpreter path…” and type it in there?
@katsar0v
Thanks for the bug report! We investigate issues in order based on priority and severity, which includes the impact it has on your ability to use the extension to do productive work, and the number of people affected. If other users come forward and leave a comment demonstrating they are seeing/reproducing the problem then we will raise this issue’s priority.
If you think your issue is more of a question or configuration problem rather than a bug, please ask on Stack Overflow with the
visual-studio-code
andpython
labels for help.Thanks for your understanding and patience!