简体   繁体   English

无法在 MacOS 终端中运行 Anaconda

[英]Can't run Anaconda in MacOS terminal

I installed Anaconda on MacOS.我在 MacOS 上安装了 Anaconda。 I tried to run the conda command in terminal, but I got the following error message:我尝试在终端中运行 conda 命令,但收到以下错误消息:

****/Users/rodalbert/.anaconda/navigator/a.tool ; exit;
/Users/rodalbert/.bash_profile:export:3: not an identifier: 2018.12
➜  ~ /Users/rodalbert/.anaconda/navigator/a.tool ; exit;
/Users/rodalbert/.anaconda/navigator/a.tool: line 1: syntax error near unexpected token `('
/Users/rodalbert/.anaconda/navigator/a.tool: line 1: `bash --init-file <(echo "source activate /Users/rodalbert/anaconda3;")'
[Process completed]****

I can't find the problem.我找不到问题。 Does someone know what to do in this case?有人知道在这种情况下该怎么做吗?

Content of .bash_profile .bash_profile 的内容

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/Applications/Postgres.app/Contents/Versions/11/bin/psql:$PATH# added by Anaconda3 2018.12 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 <<<
# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/rodalbert/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/rodalbert/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/rodalbert/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/rodalbert/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

It seems like you're using Zsh.看起来您正在使用 Zsh。

Before executing any command from within Anaconda Navigator, try opening your Terminal app and switching shell to bash: chsh -s /bin/bash then restart terminal.在 Anaconda Navigator 中执行任何命令之前,请尝试打开您的终端应用程序并将 shell 切换到 bash: chsh -s /bin/bash然后重新启动终端。

After you're done with Anaconda, switch back to Zsh: chsh -s /bin/zsh then restart terminal.完成 Anaconda 后,切换回 Zsh: chsh -s /bin/zsh然后重新启动终端。

I used MohammadChavos 's solution, then conda can run on the terminal.我使用了MohammadChavos的解决方案,然后 conda 可以在终端上运行。

cd /path/to/anaconda/bin
./conda init zsh
or:
zsh conda init zsh

My case: cd opt/anaconda3/bin, then run: ./conda init zsh我的情况:cd opt/anaconda3/bin,然后运行:./conda init zsh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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