Shell启动python虚拟环境,运行python脚本
Shell启动python虚拟环境
运行虚拟环境下脚本
#!/bin/bash
echo -n "开始执行爬虫"
export PATH="/root/anaconda3/bin:$PATH"
source activate weixin_wechat
cd /home/weixin_wechat && python /home/weixin_wechat/upload_news.py
cron 定时运行
50 19 * * * bash /home/weixin_wechat/run.sh >>/home/logs/$(date +"\%Y-\%m-\%d-\%H-\%M")weixin_run.log 2>&1
如何寻找python的安装位置
# which python
> /root/anaconda3/envs/weixin_wechat/bin/python
参考:
Linux设置anaconda的环境变量_m0_37041325的博客-CSDN博客]
Ubuntu16.04中激活tensorflow环境时出现错误“-bash: activate: No such file or directory”的解决方法。_Stephen的博客-CSDN博客]
Linux系统安装anaconda后添加环境变量:python cmd not found_Reach Higher-CSDN博客]