无法在MacOS的终端机上运行conda [英] Cannot run conda in terminal on MacOS
问题描述
我在MacOS的终端窗口中运行conda
命令时遇到问题.我知道我并不孤单,因为我已经研究了这个问题的许多答案,但仍然无法解决.这是我专门做的.
I have problems running the conda
command in a terminal window on MacOS. I know I am not alone, because I have researched many answers to this question, yet still cannot solve it. Here is what I did specifically.
我从此处下载了适用于macOS的Anaconda3 2019.10(Python 3.7版本,64位图形安装程序(654 MB)):
I downloaded Anaconda3 2019.10 for macOS (Python 3.7 version, 64-Bit Graphical Installer (654 MB)) from here: https://www.anaconda.com/distribution/ and installed it using all default settings.
我在Mac上打开了一个终端窗口以运行conda --version
.然后它说:
conda: Command not found.
I opened a terminal window on my mac to run conda --version
. Then it says:
conda: Command not found.
我读过各种文章,说您需要修改您的~/.bash_profile
,所以我open ~/.bash_profile
看起来像这样:
I have read various posts saying that you need to modify your ~/.bash_profile
, so I open ~/.bash_profile
and it looks like this:
# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/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"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
然后我添加了这一行:
export PATH=/opt/anaconda3/bin:$PATH
这没有解决.当我改用以下任何一行时:
This did not solve it. When I instead used any of the lines:
export PATH=~/anaconda3/bin:$PATH
export PATH=$PATH:$HOME/anaconda3/bin
export PATH=$PATH:$HOME/opt/anaconda3/bin
这也没有解决.
在终端窗口中,我还尝试在各种文件夹/目录(尤其是/anaconda3
子文件夹)中运行conda
命令,但也没有运气.
In a terminal window, I also tried to run the conda
command in various folders/directories, especially /anaconda3
sub-folders, but no luck either.
每次我打开终端并尝试运行conda --version
来查看它是否工作时,都会显示:conda: Command not found.
我不知道该怎么办了.有人可以帮忙吗?
Every time I open terminal and try to run conda --version
to see if it works, it says: conda: Command not found.
I don't know what to do anymore. Could anyone help, please?
推荐答案
从macOS 10.15开始,默认的shell不是bash,而是zsh.它可能可以解释为什么修改您的.bashrc
并没有帮助.
Since macOS 10.15, the default shell is not bash, but zsh. It might explain why modifying your .bashrc
did not help.
根据常见问题解答,您应该怎么做?如果conda
设置不正确,可以不手动修改PATH
变量,而是尝试运行
According to the FAQ, what you should do in case conda
was not set up correctly is not to modify the PATH
variable manually, but instead try to run
source <path to conda>/bin/activate
这将激活基本环境,并确保为当前会话正确设置conda
.随后可以是:
This will activate the base environment and make sure that conda
is set up correctly for the current session. This can be followed by:
conda init
以确保将conda
添加到当前终端的正确文件中,在您的情况下可能为zsh
,而不是bash
to ensure that conda
is added to the correct files for the current terminal, which might be zsh
in your case and not bash
这篇关于无法在MacOS的终端机上运行conda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!