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 部分。
相关推荐
picked stone3 天前
conda配置channel
conda
广药门徒3 天前
Anaconda使用教程 如何conda配置多版本Python环境
开发语言·python·conda
电棍2334 天前
vscode+WSL2(ubuntu22.04)+pytorch+conda+cuda+cudnn安装系列
人工智能·pytorch·conda
纪伊路上盛名在6 天前
生信软件管家——conda vs pip
linux·python·conda·学习方法·pip
ouliten12 天前
最新版pycharm如何配置conda环境
linux·pycharm·conda
Johaden12 天前
EXCEL+Python搞定数据处理(第一部分:Python入门-第2章:开发环境)
开发语言·vscode·python·conda·excel
qq_3993380015 天前
Conda的一些常用命令
windows·conda
NLstudy3315 天前
windows配置 Conda 使用阿里云镜像源
windows·conda
两千连弹18 天前
在PyCharm中使用Anaconda中的虚拟环境
ide·python·pycharm·conda
weixin_5178895018 天前
python管理工具:conda部署+使用
开发语言·python·conda