Activate conda environments using the path instead of the conda env name
See original GitHub issueA 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:
- Create empty directory (mine was D:/TST) for project and add a random .py file (for ext to load), open in VS Code.
- Run
conda create -p ./localenv python=3.7
in that directory. - Select this environment as the Python interpreter.
- Make sure
"python.terminal.activateEnvironment": true
(or unset) in settings. - 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:
- Created 5 years ago
- Reactions:8
- Comments:22 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
into settings.json file did the trick, until the bug is fixed.
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.