question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Venv not working when in a sub directory

See original GitHub issue

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:

  1. Create dev/ folder
  2. Create venv/ in dev/
  3. Try to use the python interpreter in VSCode from dev/venv/bin/python

bug_demo

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
katsar0vcommented, Nov 7, 2020

In the meantime, what happens if you click on “Enter interpreter path…” and type it in there?

I tried to type it, the default interpreter is used instead…

1reaction
Siluncommented, Nov 7, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found