Skip to content

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

Closed
@NowanIlfideme

Description

@NowanIlfideme

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>

Metadata

Metadata

Labels

area-environmentsFeatures relating to handling interpreter environmentsarea-terminalfeature-requestRequest for new features or functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions