使用 Windows 任务计划程序安排 [Virtualenv Dependent] Python 脚本

编程入门 行业动态 更新时间:2024-10-28 02:23:31
本文介绍了使用 Windows 任务计划程序安排 [Virtualenv Dependent] Python 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想安排一个 python 脚本在每个工作日的凌晨 3 点开始并在下午 5 点休息.然而,当我需要启动 virtualenv 时问题就出现了,因为所有的包都安装在虚拟环境中.我可以让它在特定时间运行,但是我无法激活虚拟环境(我通常会输入env\scripts\activate").这是我的操作:

I want to schedule a python script to start at 3AM and break at 5PM every weekday. However the problem arises when I need to start virtualenv as all the packages are install in a virtual environment. I can get it to run at a specific time, however I can't activate the virtual environment (I'd normally type "env\scripts\activate"). Here is what my action looks like:

关于如何合并激活 virtualenv 以及我的操作应该如何破坏脚本的任何想法?谢谢

Any idea on how I can incorporate activating virtualenv and what my action should looks like to break the script? Thanks

推荐答案

执行批处理脚本 (test.bat) 而不是调用 python.exe

Execute a batch script (test.bat) instead of calling python.exe

通过复制 activate.bat 文件来创建这样的 test.bat.在 test.bat 末尾添加使用您自己的 python 文件调用 python.exe.

Create such test.bat by copying activate.bat file. At the end of the test.bat add calling python.exe with your own python file.

更多推荐

使用 Windows 任务计划程序安排 [Virtualenv Dependent] Python 脚本

本文发布于:2023-11-23 21:21:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622900.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   计划   程序   Windows   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!