Schedule a script developed in Anaconda via Windows Task Scheduler

后端 未结 2 1103
一向
一向 2021-01-21 08:08

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

相关标签:
2条回答
  • 2021-01-21 08:36

    Follow these instructions:

    • Create a bat file.
    • Then add this code:
    @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

    0 讨论(0)
  • 2021-01-21 08:45

    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.

    0 讨论(0)
提交回复
热议问题