MAC 切换到zsh后conda命令失效

方法1:编辑.zshrc文件, 添加conda路径。

  1. 我是从pychram中发现conda的路径的。在Preferences --> Project Interpreter --> 上面是现在使用的Interpreter, 点击旁边的三个点的按钮然后点击 add --> 选择 Conda Environment --> 在Exisiting environment 中会发现你anaconda的路径。我的在/opt/anaconda3
  2. 编辑.zshrc 文件, 添加 export PATH=/opt/anaconda3/bin:$PATH
  3. source ~/.zshrc 之后 conda 命令就可以使用了
  4. 终端输入 cconda init zsh

方法2:直接复制bash中的配置到 .zshrc

  1. .bash_profile中复制conda相关的内容,粘贴到.zshrc中,也就是下面的内容
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
 __conda_setup="$('/opt/anaconda3/bin/conda' 'shell.zsh' '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"
     else
         export PATH="/opt/anaconda3/bin:$PATH"
     fi
 fi
 unset __conda_setup
 # <<< conda initialize <<<

方法3:

先切回bash,然后输入命令conda init zsh 然后切回zsh

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容