简体   繁体   中英

Why is Anaconda source activate non-existent?

I successfully created two separate Python environments in Anaconda, yet seem to be unable to activate either one of them. I have tried to read up on this topic as much as possible here on Stackoverflow, yet no solution did resolve my issue. I added information asked for by comments in this question ( Anaconda Environment Doesnt activate ).

When trying to activate an environment, the console output is -bash: activate: No such file or directory .

The output of which conda is /Users/username/anaconda3/bin/conda . The output of type source is source is a shell builtin . When trying which activate , the shell returns nothing.

In my bin folder, I also seem not to have an activate executable, but only one which is called activate-global-python-argcomplete .

Why do I lack the standard activate file and how I could resolve this issue best?

I think you happened to install a buggy version of anaconda which was quickly patched.

conda update conda

should get you back up and running.

I experience a similar problem. In my case, the problem is related to the use of the tcsh , but activate only supports bash and zsh .

You can check your current used shell with the command echo $0 .

You have to use a compatible shell in order to use the source activate command.

Start a new terminal and try again. Alternatively, type hash -r and see if it helps.

Do not do this!!!, this broke my dnf

First I tried to point source to a activate file,

source /usr/lib64/python3.6/venv/scripts/common/activate environment

That appeared to work, but no actual values got updated. I tried the answer by mattexx, but it complained conda wasn't installed, so I used.

conda install conda

I had to have root permission since it was being installed to the root environment, but after that everything appears to work.

That is what broke my fedora installation

tcsh was the problem for me. Changed to bash and all is ok.

My problem was that file /opt/pycharm/plugins/terminal/.zshrc (using ZSH) contained line source $JEDITERM_SOURCE . That variable contained correct paths as two parameters <path-to-anaconda-activate>/activate <path-to-anaconda> , but apparently they got interpreted as a single parameter: <path-to-anaconda-activate>/activate <path-to-anaconda> .

I solved that prepending eval to that line, making it eval source $JEDITERM_SOURCE . Now, the variable expands correctly.

If you're using bash then make the same change to /opt/pycharm/plugins/terminal/jediterm-bash.in .

In this case, the problem might be that the virtual environment was created in /Users/username/anaconda3/envs/ and hence the activate will be in: /Users/username/anaconda3/envs/NAME_OF_YOUR_VIRTUAL_ENV/bin/activate

Hence to activate the environment you could run:
source /Users/username/anaconda3/envs/NAME_OF_YOUR_VIRTUAL_ENV/bin/activate

I'm using the bash shell inside pycharm and fixed the problem by making this change:

[~/opt/pycharm-community/plugins/terminal]$ diff jediterm-bash.in.old jediterm-bash.in
65c65
<   source "$JEDITERM_SOURCE"
---
>   eval source "$JEDITERM_SOURCE"

Essentially making the same change recommended above by https://stackoverflow.com/users/1564931/netchkin , but to ~/opt/pycharm-community/plugins/terminal/jediterm-bash.in .

This fixed my existing projects. But any new projects don't seem to try and activate the conda environment at all. It seems as if new projects created in Pycharm 2017.1.2 don't set the JEDITERM_SOURCE variable when starting a session in the terminal plugin.

There is an open issue on this at https://youtrack.jetbrains.com/issue/PY-23417

Looks like there was a big change to the conda activate script in version 4.4.0. See https://conda.io/docs/release-notes.html . If I downgrade conda to 4.3.34 then I can get conda virtual environments to work in the pycharm terminal again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM