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 detected when created with Anaconda base environment

See original GitHub issue

Environment data

  • VS Code version: 1.36.1
  • Extension version: 2019.8.29288
  • OS and version: Windows 10 1803 b17134.885
  • Python version: Python 3.7.4, Anaconda 4.7.11
  • Type of virtual environment used: venv, conda
  • Relevant/affected Python packages and their versions: N/A
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): false

Expected behaviour

No matter which anaconda environment is active after running python -m venv venv, the extension will detect the new python environment in the folder venv.

Actual behaviour

The extension does not detect venvs created from the base environment, but will if created from another environment.

Steps to reproduce:

  1. Install anaconda, then run conda init from the anaconda PowerShell prompt and restart. This adds the following to your profile:
(& "C:\Users\GGallo\AppData\Local\Continuum\anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
  1. In VS Code, create a clean directory and cd inside. Make this the base of a new workspace. The rest happens on an integrated terminal.
  2. conda activate to make sure you have the base environment.
  3. python -m venv venv. Check for new interpreters, the new venv does not appear.
  4. rm -Recurse -Force .\venv
  5. conda create --name test python
  6. conda activate test
  7. python -m venv venv. Check for new interpreters, there it is!

Sorry I can’t GIF this whole thing, not an option right now.

You can even conda remove --name test --all and the venv will continue operating as normal.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
brettcannoncommented, Sep 18, 2019

@ggallo it is an atypical setup because you need to have the conda environment activated in order for things to work appropriately.

But in your screenshot you have source/ open, but your virtual environment is in source/clean/venv. We only automatically detect at the top of your open folder, so we would never notice that virtual environment. I would either create directly under source/ or set "python.venvPath" to point to clean to notice that venv/ folder.

0reactions
DonJayamannecommented, Sep 19, 2019

Thanks for figuring that out @brettcannon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conda environment not showing up in VS Code - Stack Overflow
in vscode press ctrl+shift+p and type python:Select Interpreter you should see all the environment there. If it does not appear create a .py ......
Read more >
Using Python environments in VS Code
If you are creating an environment using Venv, the command presents a list of interpreters that can be used as a base for...
Read more >
Setting up Environments
There are multiple ways you can create environment. We'll mainly focus on creating python3 based conda environment and native virtual environment .
Read more >
Set up a working environment | DataSpell Documentation
A virtual environment consists of a base interpreter and the installed ... You can select any other Python environment on your machine or...
Read more >
Introduction to Conda virtual environments
Both Conda and Venv are great at managing virtual environments (i.e. ... current working directory, we can create a virtual environment from ...
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