51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

shell 脚本中激活conda环境 ,shell python

在Shell脚本中激活conda环境 ,shell python

提示source 不存在

先检查

ls -l `which sh`

如果是 指定的dash , 那么要改回去:

ln -fs /bin/bash /bin/sh

脚本:

#!/bin/bash


source /root/miniconda3/bin/activate /root/miniconda3/envs/stockpy27
 
#cd /app/stock/stock/jishu_stock/agetdata/

python  /app/stock/stock/jishu_stock/agetdata/RunAll.py

注意这里2个 都是 是写绝对路径: 不然也会出问题

source /root/miniconda3/bin/activate /root/miniconda3/envs/stockpy27

shell中调用conda的方法_shell 脚本 conda activate-CSDN博客

有一个需要注意的地方就是,在shell脚本里面激活conda环境,shell脚本里面的脚本会在conda环境下执行,但是你在命令行是看不到进入conda环境的,因为shell脚本结束之后,conda环境就结束了.不要看到命令行终端没有进入conda环境就以为进入conda环境失败,其实是进去了的.

赞(1)
未经允许不得转载:工具盒子 » shell 脚本中激活conda环境 ,shell python