简体   繁体   中英

How to schedule a python script to run from virtual environment via task scheduler

I stumbled on an answer for basically the exact same question, but either I am implementing the solution wrong, the solution is no longer accurate, or some other issue is at play.

Run a python script in virtual environment from windows task scheduler

I used the code from above link, edited for my directories, and copied directly into the task scheduler program/script prompt.

C:\Users\I511843\myenv\activate.bat && python C:\Users\I511843\Desktop\Atom_scripts\test.py

I then set the program to run every time I unlocked the machine. The program simply writes a text file called test.txt containing the text "success!"

The text file populates in the correct directory when I run from the command line, however, the program doe snot execute from the task scheduler.

Did you try putting the commands in a batch file and executing the batch file from task scheduler? Something like below:

C:\\Users\\I511843\\myenv\\activate.bat && python C:\\Users\\I511843\\Desktop\\Atom_scripts\\test.py goes into task.bat file.

In task scheduler, run task.bat from cmd.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM