I am currently making my first steps with Python and try to get Anaconda running on my mac (macOS Catalania 10.15) as my default option for python. When I type "python" in my terminal though, it is still Python 2.7 that is showing up.
I found out that in order to run anaconda as a default, I need to customize my.bash_profile. But as it seems, anaconda is already set there:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
I found this question that seems to solve the same problem, but I am not sure how to apply the solution of it to my problem. A comment there states, that starting with macOS 10.15 I need to change the.zprofile. Unfortunately, I can't find the file.
Mac using default Python despite Anaconda install
I would be very greatful if any of you guys could help out! René
Catalina by default runs zsh
, which you can confirm with echo $0
. The file you changed works for bash
.
Copy the following anaconda init lines to .zshrc
and you should be good to go:
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
The only difference with respect to your file is replacement of shell.bash
with shell.zsh
.
Most commonly, the installation is fine but you can't see that until you refresh your terminal window. Just close it and open a new one.
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.