I installed Anaconda via command line. The bash file.
If Im in bash, I can open and use anaconda, like notebooks, ipython, etc.
If I change my shell to ZSH, all the anaconda commands appear like "not found".
How I can make it work in zsh?
I use a Mac with OSx Sierra.
Thanks in advance,
I had a similar issue.
I checked in my .profile, .bashrc, and .bash_profile dot files in order to find any PATH information that I could copy over into my .zshrc file. Sure enough:
# added by Miniconda3 4.2.12 installer
export PATH="/Users/username/miniconda3/bin:$PATH"
After running source ~/.zshrc with those lines added, I could fire up my jupyter notebook server.
Since conda 4.4.0 (released 2017-12-20), the recommended way to add conda to your PATH has changed. Instead of the approach described in Jonathan's answer, this should be done using the conda.sh script in the etc/profile.d/ folder of your conda installation. After that you can activate the base environment. More information on why this is the case can be found in the conda changelog.
I needed to add the following lines to my .zshrc:
. ~/miniconda3/etc/profile.d/conda.sh
conda activate base
This assumes that (mini)conda was installed with default parameters, i.e. into the home folder.
Following up on @m00am's answer, as of Anaconda 4.5.11, the bash code Anaconda adds to .bashrc seems to run perfectly well also in zsh, so copying that into your .zshrc works well. In my case, the code looked like this:
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/my-account/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/home/my-account/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/my-account/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/home/my-account/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
This worked for me on my macOS
https://medium.com/@sumitmenon/how-to-get-anaconda-to-work-with-oh-my-zsh-on-mac-os-x-7c1c7247d896
Open the .bash_profile file using:
open ~/.bash_profile
There’s a block of code the anaconda installer added to the end of the file. Copy that.
Mine looks something like this:
# added by Anaconda3 5.3.0 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
. "/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
Now open your .zshrc file:
open ~/.zshrc
Run
source ~/.zshrc
When on iterm2 or the terminal, you should see a (base) pop up in there
Altough I cannot test it on a Mac, (I have a Linux Zsh installed) this should work for you as well: Just execute
/(your conda installation path)/bin/conda init zsh
and restart your zsh shell. The init command will change your ~/.zshrc file accordingly, setting your PATH correctly and slightly change the PS1 (which is was most answers here do manually...).
You need to set your path variable for the ZSH environment. The easy way to do this would be to set your path variable in your .zshrc file to include the location of Anaconda. To get the path in your bash terminal type which anaconda
You can also check this out from http://unix.stackexchange.com
This solution worked for me on macOS Mojave
If you use version 2019.03 of Anaconda you can update your .zshrc file with
# Anaconda
. /anaconda3/etc/profile.d/conda.sh
conda activate base
after saving file don't forget to run source ~/.zshrc.
After upgrading to Catalina
If you install a new Anaconda3 2019.07 you can use solution below.
open ~/.bash_profile
Copy the line starts with # added by Anaconda3 2019.07 installer and ends with # <<< conda init <<< and paste into .zshrc. Then run source ~/.zshrc.
in my original profile, which is .bash_profile, it looks like this:
### added by Anaconda3 4.4.0 installer
export PATH="/Users/myname/anaconda/bin:$PATH"
and now i open the file .zshrc, add the sentence above to it, it goes all right now.
I had a similar issue after I installed anaconda3 in ubuntu.
This is how I solved it:
1) I changed to bash and anaconda can work
2) I changed to zsh, and anaconda works. I don't know why, but I think you can try.
In .bashrc
zsh
In .zshrc
conda activate base
all exports should be resolved
only if you do not use chsh
来源:https://stackoverflow.com/questions/40370467/anaconda-not-found-in-zsh