导读
常用的conda activate切换conda环境的方法只能在命令行中使用,放在脚本中会报错,该如何解决呢?
一、脚本中使用conda activate
vi ztest.sh
conda activate metawrap-env
conda info --envs
bash ztest.sh
凉凉
二、bing我的问题
后来bing一下,看到了一篇文章:
Can't execute conda activate from bash script
三、source ~/conda.sh解决问题
1 my path to miniconda
conda info | grep -i 'base environment'
2 尝试使用source ~/conda.sh
vi ztest.sh
source /home/cheng/miniconda2/etc/profile.d/conda.sh
conda activate metawrap-env
conda info --envs
bash ztest.sh
3 多次conda env切换也OK
vi ztest.sh
source /home/cheng/miniconda2/etc/profile.d/conda.sh
conda activate metawrap-env
conda info --envs
conda activate base
conda info --envs
conda activate python3.6
conda info --envs
bash ztest.sh