I\'m trying to use Windows Task Scheduler to run a script in python and write a csv file. I\'ve always used Anaconda, so I don\'t understand how Python\'s command line works. If
Follow these instructions:
@ECHO OFF
TITLE Execute python script on anaconda environment
ECHO Please Wait...
:: Section 1: Activate the environment.
ECHO ============================
ECHO Conda Activate
ECHO ============================
@CALL "C:\Users\user\AppData\Local\Continuum\anaconda3\Scripts\activate.bat" TestEnvironment
:: Section 2: Execute python script.
ECHO ============================
ECHO Python test.py
ECHO ============================
python C:\Users\user\PycharmProjects\Test\test.py
ECHO ============================
ECHO End
ECHO ============================
PAUSE
Ref Run a python script in virtual environment from windows task scheduler
To use pip
, you need to run it from the Windows Command Prompt, CMD.EXE
. It should show up if you type cmd
at the Start menu.
When you go to schedule a Python script, use the "create a basic task" wizard (the full version is needlessly complicated), set the action to "start a program," the program to run as python.exe
, and put the script's path and arguments in the arguments box.