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 部分。
相关推荐
Echo_NGC22374 小时前
【论文解读】Attention Is All You Need —— AI 时代的“开山之作“,经典中的经典(transformer小白导读)
人工智能·python·深度学习·神经网络·机器学习·conda·transformer
何中应5 小时前
Conda安装&使用
python·conda·python3.11
qq_229058011 天前
conda中安装 rdkit版本的postgresql然后在Win11中使用虚拟环境里的rdkit
数据库·postgresql·conda
独隅4 天前
Anaconda被误删后抢救手册
conda
矢志航天的阿洪4 天前
手动安装Gurobi并配置gurobipy到Python环境(Windows/Conda)
windows·python·conda
可西可彻5 天前
# 【拾零】0 - 开箱即用的现代风终端 |Ghostty + Fish + Starship + fzf + zoxide + Raycast
终端·fzf·fish·starship·raycast·zoxide·ghostty·teminal
GL_Rain5 天前
conda通过environment.yml创建虚拟环境(指定路径)报错解决教程
conda
雕刻刀8 天前
linux中复制conda环境
linux·python·conda
乐园游梦记8 天前
在pycharm中添加Conda创建的openmmlab虚拟环境作为解释器
ide·pycharm·conda
贵沫末9 天前
Python——图像处理项目Conda环境搭建
开发语言·python·conda