Skip to content

Fix No such file or directory on conda activate #15818

Description

Environment data

  • VS Code version: 1.54.3
  • Extension version (available under the Extensions sidebar): v2021.3.680753044
  • OS and version: linux x64 5.9.16-1
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.2 conda 4.9.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python-related VS Code extensions and their versions: Jupyter v2021.3.684299474
  • Value of the python.languageServer setting: Jedi

Expected behaviour

for the command '. activate' to work in integrated terminal. (but the source command DOES work!- i.e source activate & conda activate)

Actual behaviour

. activate returns an error: No such file or directory, but weirdly enough - the command will work after deactivating the environment:
image

Steps to reproduce:

  1. . activate conda_env_name

Consequence

This is actually affecting a error when using the jupyter extension: whenever I need to activate a virtual environment other than base in a notebook, the following command is used:

. activate mech && echo etc.

returning a command failed message saying: activate: No such file or directory.
image

I've had this problem in the past, and it disappeared for a while, but now it's back.
Also, a weird observation: if code is called from terminal, this issue does not happen.

Activity

  1. karrtikr commented on Mar 31, 2021

    @karrtikr

    Thanks for the bug report! We investigate issues in order based on priority and severity, which includes the impact it has on your ability to use the extension to do productive work, and the number of people affected. If other users come forward and leave a comment demonstrating they are seeing/reproducing the problem then we will raise this issue's priority.

    Thanks for your understanding and patience!

  2. karrtikr commented on Apr 5, 2021

    @karrtikr

    Can you try this?

    1. Anaconda prompt and cd to your workspace.
    2. Activate the environment using conda activate
    3. Start VS Code using code .

    related #10626

  3. RicardoSQueen commented on Apr 6, 2021

    @RicardoSQueen
    Author

    Hey, Kartik Raj (@karrtikr).

    Apparently it's a well known issue! I'm sorry if I missed it from the issues page. starting vscode from conda prompt did solve it!

    Thanks for your attention!

  4. changed the title [-]Weird behaviour in Integrated Terminal[/-] [+]. activate script sent to activate a conda environment[/+] on Apr 6, 2021
  5. changed the title [-]. activate script sent to activate a conda environment[/-] [+]. activate script sent fails when activating a conda environment[/+] on Apr 6, 2021
  6. karrtikr commented on Apr 6, 2021

    @karrtikr

    Yes, your issue seems very similar to earlier issues like this one #14123 (comment). conda activate is more reliable than source activate or . activate, so we'll change the code to do that instead, so you don't need to open VSCode using conda prompt everytime.

  7. changed the title [-]. activate script sent fails when activating a conda environment[/-] [+]Use `conda activate` instead of `source activate`/`. activate` to activate a conda environment for newer versions[/+] on Apr 6, 2021
  8. 8 remaining items

  9. moetayuko commented on Oct 19, 2021

    @moetayuko

    Hello Kartik Raj (@karrtikr) , is there any progress on the migration? It's been half a year since the solution was proposed but the issue is still not fixed.

  10. karrtikr commented on Oct 19, 2021

    @karrtikr

    Unfortunately we haven't been able to prioritize it, although there is a long term goal (#11039). The issue is here:

    const firstActivate = this.platform.isWindows ? activatePath : `source ${activatePath}`;
    we're happy to take external contributions as well.

  11. mivade commented on Nov 4, 2021

    @mivade

    I came here by way of #8770. I've started using conda create -p {directory} more often than using named environments and it's really obnoxious that I have to manually activate the environment when it works as expected for conda environments created with -n.

  12. MetRonnie commented on Nov 24, 2021

    @MetRonnie

    To workaround this I had to find the location of my activate executable and set python.condapath to the conda executable in the same directory.

    I my case activate was at /opt/conda/bin/activate so I set python.condapath to /opt/conda/bin/conda. (Even though which conda results in a different path: /opt/conda/condabin/conda)

    image

  13. MetRonnie commented on Apr 6, 2022

    @MetRonnie

    Currently when you launch an integrated terminal, you have to wait as it does this:

    source /opt/conda/bin/activate
    conda activate myenv
    user@host:~ $ source /opt/conda/bin/activate
    (base) user@host:~ $ conda activate myenv
    (myenv) user@host:~ $ 
    

    The source is not needed and a waste of time

  14. mokeyish commented on Apr 24, 2022

    @mokeyish

    Activate enviroment myml returns an error: No such file or directory when the enviroment is created by non-root user.

    This env list in my system. machine-learning is global env (created by root user), myml is user env (created by user deep).

    图片

    • env create by non-root user.
      图片

    • env create by root user.
      图片

  15. mokeyish commented on Apr 24, 2022

    @mokeyish

    Hello, I have fixed this issue in PR #18989

  16. changed the title [-]Use `conda activate` instead of `source activate`/`. activate` to activate a conda environment for newer versions[/-] [+]Fix No such file or directory on conda activate[/+] on Jun 6, 2022
  17. karrtikr commented on Jun 6, 2022

    @karrtikr

    Fixed with #18989.

  18. karrtikr commented on Jun 6, 2022

    @karrtikr

    Fix should be out in the pre-release version of the extension, use the following to try it out:

    image

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions