Skip to content

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

Description

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>

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Jan 1, 2019
  2. NowanIlfideme commented on Jan 1, 2019

    @NowanIlfideme
    Author

    Note that all conda environments made with the -p argument will fail this way.

    Also, the environment docs show this working with the virtualenv, but it has conda directly next to it (second image). I understand if this is just in the "not yet implemented" territory (I've read that you've been seeking to talk more closely with the Anaconda team), just slightly misleading as it currently is shown.

  3. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 2, 2019
  4. ericsnowcurrently commented on Jan 9, 2019

    @ericsnowcurrently

    Hi Anatoly Makarevich (@NowanIlfideme). Thanks for letting us know about this. I wasn't able to duplicate the issue just by opening a (Python) terminal. However, I did see the problem when opening a REPL. We'll investigate further.

  5. faroit commented on Mar 14, 2019

    @faroit

    This issue is does also trigger a problem when using the "install linter" command

  6. gonzalocasas commented on Mar 15, 2019

    @gonzalocasas

    I am seeing the same issue with local conda environments created with prefix (e.g. -p ./env). Discovery works but then activation fails every time I open a new terminal (cmd in my case).

  7. sindzicat commented on Mar 27, 2019

    @sindzicat

    The same problem.

  8. 24 remaining items

  9. changed the title [-]Activate coda environments using the path instead of the conda env name[/-] [+]Activate conda environments using the path instead of the conda env name[/+] on Nov 5, 2019
  10. kimadeline commented on Nov 12, 2019

    @kimadeline

    ✅ Validated using 2019.12.48501-dev

  11. locked as resolved and limited conversation to collaborators on Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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