『开发技术』解决 MacOS command not found: conda (zfh终端)

0. 问题描述

最近升级了macos系统,安装miniconda遇到问题,在终端输入 conda 指令报错:command not found: conda

笔者使用 指令 sudo vim ~/.bash_profile 发现 .bash_profile已经配置好conda path,内容如下:


(base) xshine@ShinedeMBP-742f ~ % sudo vim .bash_profile
Password:

...
# added by Miniconda3 4.7.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/xshine/opt/miniconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/xshine/opt/miniconda3/etc/profile.d/conda.sh" ]; then
# . "/Users/xshine/opt/miniconda3/etc/profile.d/conda.sh"  # commented out by conda initialize
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/xshine/opt/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
复制代码

笔者分析应该不是.bash_profile的配置原因,如果大家的.bash_profile没有conda信息,可以将下述添加到.bash_profile,然后使用source 激活:注意 /Users/xshine/opt/miniconda3/bin 要用自己电脑安装的地址。

export PATH=”/Users/xshine/opt/miniconda3/bin:$PATH”

1.  问题解决

后来在简书上找到一个文章:www.jianshu.com/p/e84cda5c0…

打开命令行的时候不在执行~/.bash_profile,如果要想让这个文件有效,那么修改 zsh 的配置文件:

编辑~/.zshrc,在文件里加入一行:

source ~/.bash_profile

具体操作如下:

  1. sudo vim ~/.zshrc 
  2. 添加一行 :source ~/.bash_profile,退出保存
  3. source ~/.bash_profile

重新打开一个终端就可以了。

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享