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.

Activating prefix conda environment does not work when in discovery experiment

See original GitHub issue

Environment data

  • VS Code version: Version: 1.55.0 (user setup) Commit: c185983a683d14c396952dd432459097bc7f757f Date: 2021-03-30T16:01:55.261Z OS: Windows_NT x64 10.0.18363

  • Extension version (available under the Extensions sidebar): v2021.3.680753044

  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.9 64bit - Anaconda

  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda

Task

Load a conda environment, located at ./.venv from the terminal.

Expected behaviour

Conda environment loaded properly after selecting the interpreter and open a new terminal.

Actual behaviour

Not loaded. The error message is as follows:

C:\Users\xxxxx\AppData\Local\Continuum\anaconda3\Scripts\activate .venv
Could not find conda environment: .venv
You can list all discoverable environments with `conda info --envs`.

It’s possible to activate conda’s base environment and run conda activate ./.venv to activate the virtual environment, but that doesn’t help because when I highlight and run the code, it opens a new terminal then fails to load the virtual environment.

Steps to reproduce:

  1. Create a conda environment at ./.venv: conda env create -f requirements.yml --prefix ./.venv
  2. Select the interpreter by Ctrl + Shift + P
  3. Python: Select interpreter,
  4. Select \.venv\python.exe
  5. Open a new terminal

Logs

User belongs to experiment group 'pythonaa'
User belongs to experiment group 'pythonSendEntireLineToREPL'
User belongs to experiment group 'pythonNotDisplayLinterPrompt'
User belongs to experiment group 'pythonDiscoveryModuleWithoutWatcher'
User belongs to experiment group 'pythonTensorboardExperimentcf'
User belongs to experiment group 'pythonFindInterpretercf'
User belongs to experiment group 'PythonPyTorchProfiler'
User belongs to experiment group 'CollectLSRequestTiming - experiment'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'DeprecatePythonPath - control'
Python interpreter path: .\.venv\python.exe
Starting Jedi Python language engine.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
wags1999commented, Apr 1, 2021

Yes, this is affecting all of the users doing Python development at my company. Thanks @xquyvu for the work-around!

1reaction
xquyvucommented, Mar 31, 2021

I’ve managed to get it working by adding this in the settings.json.

    "python.experiments.optOutFrom": [
        "All"
    ]

Before opting out:

C:\Users\xxxxx\yyyyy>C:\Users\xxxxx\AppData\Local\Continuum\anaconda3\Scripts\activate .venv
Could not find conda environment: .venv
You can list all discoverable environments with `conda info --envs`.

C:\Users\xxxxx\yyyyy>

After opting out:

C:\Users\xxxxx\yyyyy>C:\Users\xxxxx\AppData\Local\Continuum\anaconda3\Scripts\activate c:\Users\xxxxx\yyyyy\.venv

'(.venv)'C:\Users\xxxxx\yyyyy>

Looks like an “experiment” is removing the path to the virtual environment which makes it cannot be found. The issue is going to be inevitable when this experiment goes live.

Please help address this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

anaconda - Conda activate not working? - Stack Overflow
The procedure to add conda to the PATH environment variable for non-Windows platforms (on Windows you should use the Anaconda Prompt), as well ......
Read more >
Managing environments - Conda
With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them.
Read more >
Working with Conda/Miniconda/Anaconda
To activate your Conda environment, type source activate <yourenvironmentname> . Note that conda activate will not work on Discovery with this version.
Read more >
Add Python packages using the conda package manager
At the end of the conda create step, you may saw a message from the installer that you can use conda activate command...
Read more >
(How to) Install and use Conda for GATK4 – GATK
Both Conda and Docker are intended to solve the same problem, but one of the ... Run: conda env create -n gatk -f...
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