Schedule a Python script via batch on windows (using Anaconda)

后端 未结 4 1715
别跟我提以往
别跟我提以往 2020-12-09 04:29

I have a script that i run every day and want to make a schedule for it, i have already tried a batch file with:

start C:\\Users\\name\\Miniconda3\\python.exe

4条回答
  •  [愿得一人]
    2020-12-09 04:50

    I'd recommend creating an Anaconda environment with the packages you need, then using the python from that environment to run your script. Read about Anaconda environments here

    For example...

    Say you create an environment called cristians_env

    conda create --name cristians_env
    

    and you install the packages you need

    conda install pandas
    

    Then, all you need to do is this from your batch script (assuming you use Anaconda 2)

    start C:\Users\name\Anaconda2\envs\cristians_env\bin\python C:\script.py
    

    and voila! You're using your anaconda environment from your batch script!

提交回复
热议问题