fish终端下conda activate失败

【问题】fish终端下激活conda环境报错:

bash 复制代码
>> conda activate base    
CondaError: Run 'conda init' before 'conda activate'
## 然而运行 conda init fish 仍旧无法解决

【解决】

参考:https://github.com/conda/conda/issues/11079

方法一:更新fish2至fish3版本

bash 复制代码
## ubuntu
sudo apt-add-repository ppa:fish-shell/release-3
sudo apt update
sudo apt install fish

方法二:不更新fish,修改config.fish配置文件

将以下代码加至fish配置文件中,重启fish

bash 复制代码
function conda --inherit-variable CONDA_EXE
    if [ (count $argv) -lt 1 ]
        eval $CONDA_EXE
    else
        set -l cmd $argv[1]
        set -e argv[1]
        switch $cmd
            case activate deactivate
                eval (eval $CONDA_EXE shell.fish $cmd $argv)
            case install update upgrade remove uninstall
                eval $CONDA_EXE $cmd $argv
                and eval (eval $CONDA_EXE shell.fish reactivate)
            case '*'
                eval $CONDA_EXE $cmd $argv
        end
    end
end
环境名在fish shell左侧显示:

fish 配置文件(~/.config/fish/config.fish)中加入:set -gx CONDA_LEFT_PROMPT 1

更全的使用请参考文章安装和配置 Anaconda 中 fish shell 部分。
相关推荐
weixin_447195291 天前
Conda 创建新环境时报错 HTTP 502,如何解决?
网络协议·http·conda
鹏说大数据3 天前
使用Conda管理服务器多版本Python环境的完整指南
服务器·python·conda
leon_zeng03 天前
在 Conda 环境下配置 Jupyter Notebook 环境和工作目录
linux·jupyter·conda
ғᴀɴᴛᴀsʏ3 天前
解决windows下pycharm终端conda无法激活虚拟环境问题
pycharm·conda·虚拟环境
弱冠少年7 天前
conda入门
conda
John Song7 天前
conda指定包安装的channel
conda
Gene_20227 天前
conda环境配置(一) —— 常用虚拟环境操作命令
conda
Calvex7 天前
PyCharm集成Conda环境
python·pycharm·conda
晓枫-迷麟8 天前
【使用conda】安装pytorch
人工智能·pytorch·conda
拾回程序猿的圈圈∞9 天前
PyCharm项目和文件运行时使用conda环境的教程
windows·pycharm·conda