我使用的是 Catalina macOS。我以前能够在这个系统上轻松地使用我的 python 安装。但是今天在更新其他软件包(例如 wget 和 julia)后,我在终端上遇到了这些错误 zsh: command not found: python3.8
。按照 these links 上的建议,我尝试修改 PATH 和 zshrc,但这些方法都无法解决我的问题。
如果您能就如何处理此问题分享您的建议,我将不胜感激。
这是我系统的一些输出。
zshrc:
vi ~/.zshrc
alias python=/usr/local/bin/python3.8
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/shasa/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/shasa/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/shasa/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/shasa/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
蟒蛇:
which python
python: aliased to /usr/local/bin/python3.8
路径:
echo $PATH
/Users/shasa/anaconda3/bin:/Users/shasa/anaconda3/condabin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin
编辑 1:在 /usr/local/bin/
中,我可以看到存在 python3@、python3.9@ 和 python3.8@*。你认为 python3.8@ 附近的额外 * 会导致这个问题吗?如果是,如何解决?
答案 0 :(得分:0)
经过评论中的讨论,我找到了问题的根源。我运行 brew doctor
并确实发现 python3.8 符号链接已损坏。然后我通过 brew cleanup
删除了损坏的符号链接并重新安装。