『开发技术』解决 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.  问题解决

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

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

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

source ~/.bash_profile

具体操作如下:

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小宋是呢

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值