【问题】fish终端下激活conda环境报错:
>> conda activate base
CondaError: Run 'conda init' before 'conda activate'
## 然而运行 conda init fish 仍旧无法解决
【解决】
参考:https://github.com/conda/conda/issues/11079
方法一:更新fish2至fish3版本
## ubuntu
sudo apt-add-repository ppa:fish-shell/release-3
sudo apt update
sudo apt install fish
方法二:不更新fish,修改config.fish配置文件
将以下代码加至fish配置文件中,重启fish
function conda --inherit-variable CONDA_EXEif [ (count $argv) -lt 1 ]eval $CONDA_EXEelseset -l cmd $argv[1]set -e argv[1]switch $cmdcase activate deactivateeval (eval $CONDA_EXE shell.fish $cmd $argv)case install update upgrade remove uninstalleval $CONDA_EXE $cmd $argvand eval (eval $CONDA_EXE shell.fish reactivate)case '*'eval $CONDA_EXE $cmd $argvendend
end
环境名在fish shell左侧显示:
fish 配置文件(~/.config/fish/config.fish
)中加入:set -gx CONDA_LEFT_PROMPT 1