Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix No such file or directory on conda activate #15818

Closed
RicardoSQueen opened this issue Mar 31, 2021 · 13 comments
Closed

Fix No such file or directory on conda activate #15818

RicardoSQueen opened this issue Mar 31, 2021 · 13 comments
Assignees
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug good first issue

Comments

@RicardoSQueen
Copy link

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.

@RicardoSQueen RicardoSQueen added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Mar 31, 2021
@karthiknadig karthiknadig added area-terminal triage and removed triage-needed Needs assignment to the proper sub-team labels Mar 31, 2021
@karrtikr
Copy link

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!

@karrtikr
Copy link

karrtikr commented Apr 5, 2021

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

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Apr 5, 2021
@RicardoSQueen
Copy link
Author

Hey, @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!

@karrtikr karrtikr removed the info-needed Issue requires more information from poster label Apr 6, 2021
@karrtikr karrtikr changed the title Weird behaviour in Integrated Terminal . activate script sent to activate a conda environment Apr 6, 2021
@karrtikr karrtikr changed the title . activate script sent to activate a conda environment . activate script sent fails when activating a conda environment Apr 6, 2021
@karrtikr
Copy link

karrtikr commented Apr 6, 2021

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.

@karrtikr karrtikr 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 Apr 6, 2021
@karrtikr karrtikr removed their assignment Apr 6, 2021
@karrtikr karrtikr added needs PR and removed triage labels Apr 6, 2021
@karrtikr karrtikr reopened this Apr 7, 2021
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 7, 2021
@karrtikr karrtikr removed the triage-needed Needs assignment to the proper sub-team label Apr 7, 2021
@MoetaYuko
Copy link

Hello @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.

@karrtikr
Copy link

karrtikr commented Oct 19, 2021

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.

@mivade
Copy link

mivade commented Nov 4, 2021

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.

@MetRonnie
Copy link

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

@MetRonnie
Copy link

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

@mokeyish
Copy link

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.
    图片

@mokeyish
Copy link

Hello, I have fixed this issue in PR #18989

@karrtikr karrtikr 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 Jun 6, 2022
@karrtikr
Copy link

karrtikr commented Jun 6, 2022

Fixed with #18989.

@karrtikr karrtikr closed this as completed Jun 6, 2022
@karrtikr
Copy link

karrtikr commented Jun 6, 2022

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

image

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug good first issue
Projects
None yet
Development

No branches or pull requests

7 participants