-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Conda activation is failing #4402
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
Comments
I re-installed the Don's extension "Jupyter 1.1.4" and it nicely opens Jupyter notebook in the correct environment. So the issue is only with the new interactive python.
|
I noticed that
It tries to activate 'py36' environment while already being in it. When listing environments I get:
So in summary VSC is in 'py36' environment but incorrectly calles it 'base'. |
Not data science specific. also happened in the terminal window. |
This comment has been minimized.
This comment has been minimized.
I am not sure if you experience the same issue. I get this issue only on Windows.
On Windows I get this error (mind that it incorrectly uses ../envs/py36/../activate and not base activate):
On Linux the activation correctly uses the base conda envirnment and works nicely:
I tried on several different Windows computers using clean miniconda install and I am getting allways teh same issue. It stops me from using interactive python on Windows. The only workaround right now is to use the deprecated Don's jupyter extension, but unfortunately this does not work with python 3.7. |
This comment has been minimized.
This comment has been minimized.
|
I opened VSCOde, selected py36 interpreter and run command:
The problem seems to be that the extension tries to activate py36 environment while already being in the py36 environment, and thus cannot find it. Thank you for your time Don. |
Don, does my comment above give you all the info you need? |
How did you manage to do this? |
I never start VSCode from a terminal with an already activated conda environment. conda and python are not even on path. Correct way of activating environment is:
While it seems that VScode-python extension is activating inside of environment and then tries to activate it again:
|
Expected approach for activation:
What we're doing is as follows:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Any progress on this one? I had a workaround which worked until the latest python extension update:
|
Are you able to activate the conda environment from the terminal (manually). |
Hi Don,Yes activation of the environment form console works fine.
Comment whether or not this issue is another bugI think this issue is the same as reported above:
See the full log file in the attachment: Also if one tries to start python terminal from bug_env one gets familiar error:
and when listing conda environments in this terminal window one gets:
so bug_env is activated and fails to activate itself again. All of the above works fine in ok_env which differs just by not having conda-build: |
I ran into the same problem and tracked down the source of the issue to https://github.com/Microsoft/vscode-python/blob/8cd0996e4fbb50f5aa4ca2d05b320a370ae121a6/src/client/interpreter/locators/services/condaService.ts#L254-L262 Here we try to activate the environment using the @rchiodo Maybe you can add more context why these two blocks exist as you wrote the environment activation code initially in #3506 ? |
Sorry I must be missing something. That line of code is just looking in the Scripts folder for the conda executable next to the python that was found. Why is this causing a problem? The way this stuff was supposed to work was we call conda activate for the base and then inside the base, call the conda activate 'env-name'. It looks like we don't find the base. I'm guessing we're using the python.exe path and assuming it's for the 'base' and that there isn't one for the sub environment. For example, here's what happens on my own machine:
C:/Users/rchiodo/AppData/Local/Continuum/anaconda3/Scripts/activate is where the base conda was installed. It's next to where the python.exe is found. The 'jupyter' environment is the secondary environment it's activating. It looks like for @MarekOzana, the first activate is the wrong one. We must be using the python installed in the environment instead. |
@rchiodo The problem is only occuring when you have The following steps show the issue:
Removing the code lines I mentioned earlier resolves the problem. |
Ah that's because it doesn't find an activate so falls back to the default location. Is it normal to install conda in a test environment? Is that so you can have a different conda? |
It is not normal but still happening from time to time. You can use In the case of conda environments, I would never call the |
In contrast to virtualenv-created environments, conda environments are not activated from the inside. In constrast, the environment activation is done from the outside via the conda executable that created the environment. Fixes microsoft#4402
In contrast to virtualenv-created environments, conda environments are not activated from the inside. In constrast, the environment activation is done from the outside via the conda executable that created the environment. Fixes microsoft#4402
In contrast to virtualenv-created environments, conda environments are not activated from the inside. In constrast, the environment activation is done from the outside via the conda executable that created the environment. Fixes microsoft#4402
* Don't use activate from inside conda environments In contrast to virtualenv-created environments, conda environments are not activated from the inside. In constrast, the environment activation is done from the outside via the conda executable that created the environment. Fixes #4402 * Add NEWS
Now-a-days, conda is only ever installed in the |
Maybe to add my usecase why I have |
How have you done this? Conda prevents it! |
The bug happens when I install conda-build package (used to build and develop packages locally) inside an environment.
|
Just like with any other package:
Also it should not prevent it as I want to use the Python API of the package: https://docs.conda.io/projects/conda/en/latest/api/ |
Environment data
Expected behaviour
VSC opens interactive python using active py36 environment
Actual behaviour
Jupyter kernel cannot be started from 'Python 3.6.6 64-bit ('py36': conda)'. Using closest match Python 3.6.6 64-bit ('mro': conda) instead.
Steps to reproduce:
Logs
Relevant Part from Developer Tools > Console Log:
The problem seems to be that process is already in 'py36' environment and thus fails when trying to activate py36 again:
C:/Users/marek.ozana.XCF/AppData/Local/Continuum/miniconda3/envs/py36/Scripts/activate && conda activate py36
The text was updated successfully, but these errors were encountered: