Anaconda或者miniconda在容器中安装以后,需要手动执行一下
conda init以后才可以激活相应的环境
假设conda的安装目录prefix为
/opt/conda/
查看init以后的~/.bashrc,发现conda是根据shell的类型执行相应的安装
__conda_setup="$('/opt/conda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then
. "/opt/conda/etc/profile.d/conda.sh"
else
export PATH="/opt/conda/bin:$PATH"
fi
fi
unset __conda_setup
安装完成conda以后,直接执行相同的操作,启动/bin/bash时默认就会激活base环境
Ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc #
echo "conda activate base" >> ~/.bashrc
export PATH="/opt/conda/bin:$PATH"
如果需要激活其他环境,需要先行配置好虚拟环境
修改
echo "conda activate base" >> ~/.bashrc
为需要的环境即可