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.

Conda environment is not activated in current terminal

See original GitHub issue

Environment data

  • VS Code version: 1.43.2
  • Extension version (available under the Extensions sidebar): 2020.3.69010
  • OS and version: Win 10
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): Conda 4.8.3

Expected behaviour

Conda env should activate in current terminal on load of the extension

Actual behaviour

Conda env does not activate in current terminal on load of the extension, despite "python.terminal.activateEnvInCurrentTerminal": true.

Possible explanation

This is the same as #10782. I thought I had fixed the problem but I was wrong. What I realized is that the extension does not trigger the .../miniconda/Scripts/activate only for environments with very long names. Try for example to create a new Conda environment with

conda create -n this_is_a_very_long_environment_name python

Everything works fine if I use a shorter name.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
karthiknadigcommented, Apr 16, 2020

This particular issue with long conda env names is addressed, and the fix is in master. It will be available in the May release.

2reactions
Qsi1984commented, Apr 3, 2020

Hi. I just figured out that I have this exact same issue. Here are some pointers that might help: Responsible code: https://github.com/microsoft/vscode-python/blob/61b179b2092050709e3c373a6738abad8ce581c4/src/client/interpreter/locators/services/condaHelper.ts#L59

If the name is too long, the split-offset is wrong and part of the name is added to the path:

[
    {
        "name": "base",
        "path": "/home/my_user/miniconda3"
    },
    {
        "name": "hpc-quickstart-inferencin",
        "path": "g     /home/my_user/miniconda3/envs/hpc-quickstart-inferencing"
    }
]

which is expected if you have a look at the output of the “conda env list”-command where the / of the base-path aligns with the g that gets clipped from the path of the other environment:

base                  *  /home/u161040/miniconda3
hpc-quickstart-inferencing     /home/u161040/miniconda3/envs/hpc-quickstart-inferencing

hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

anaconda - Conda activate not working? - Stack Overflow
To do so, run $ conda activate in your terminal, or to put the base environment on PATH permanently, run $ echo "conda...
Read more >
No indication of activated conda environment in terminal
Problem. I have a local conda environment in a folder, but when I activate it, I get no indication of having done so....
Read more >
terminal not activating the conda environment : PY-23417
This will create the environment at /opt/anaconda3/envs/. After this, when starting a new project, select this environment from existing environments.
Read more >
Managing environments - Conda
Determining your current environment ... If the environment is not activated, in your terminal window or an Anaconda Prompt, run: conda list -n...
Read more >
Efficient Way to Activate Conda in VSCode - Medium
If you have problem finding the conda virtual environment path, you can open a terminal with your target conda env activated, and then...
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