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.

Activate conda environments using the path instead of the conda env name

See original GitHub issue

A project-local conda environment will be seen by VS Code, but it will fail to activate automatically. I would guess this is because it looks at the end of the path for the environment name and always activates by name, rather than by path. However, for environments created with the -p pathname flag, this will fail (as you can’t even set environments name for them with -n).

Environment data

  • VS Code version: 1.30.1
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • OS and version: Windows 10 V 1803
  • Python version: 3.7.0, conda 4.5.12
  • Type of virtual environment used: conda

Steps to reproduce:

  1. Create empty directory (mine was D:/TST) for project and add a random .py file (for ext to load), open in VS Code.
  2. Run conda create -p ./localenv python=3.7 in that directory.
  3. Select this environment as the Python interpreter.
  4. Make sure "python.terminal.activateEnvironment": true (or unset) in settings.
  5. Open new terminal (EDIT: as in interactive terminal, e.g. a REPL; for me, this was the cmd, but running code in the REPL has the same effect: it fails to activate the env, and thus runs in the default environment).

Expected behaviour

Automatic environment activation by path, rather than name:

D:\TST>activate ./localenv

(D:\TST\localenv) D:\TST>

OR

D:\TST>activate "D:\TST\localenv"

(D:\TST\localenv) D:\TST>

Actual behaviour

When opening a terminal:

D:\TST>activate localenv
Could not find conda environment: localenv
You can list all discoverable environments with `conda info --envs`.
D:\TST>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:22 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
lpravdacommented, Apr 28, 2019

I think I have found the solution eventually in some other thread here. However, don’t really know which one, so I can’t give a proper credit to the person who came up with this. However, putting:

    "terminal.integrated.env.osx": {
        "PATH": ""
    }

into settings.json file did the trick, until the bug is fixed.

2reactions
EBjerrumcommented, Aug 19, 2019

I have this issue too. Can’t use various features when I have conda environments created with -p. In my case it’s necessary to use prefixes in conda environments due to integration with our compute cluster. Looking forward to seeing a solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Activating conda environment with its full path - Stack Overflow
Navigate to the custom folder where you want to create the new environment. D:\condaEnvs>conda create --prefix=FastAI --> This creates a conda ...
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 >
PATH not set by conda activate · Issue #9392 - GitHub
Conda respects your PATH order and will not reorder anything upon activation/deactivation but instead finds the currently active environment and ...
Read more >
Manage your Python Virtual Environment with Conda
Conda can no longer find your environment by your environment name, you will have to specify the environment's full path to activate it ......
Read more >
Working with Environments – Introduction to Conda for (Data ...
You can activate an existing environment by providing the path the the environment directory instead of the environment name when using the conda...
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