I want my Windows computer to automatically run a Python script every day, using the Task Scheduler. I wrote my Python Script using Spyder (Anaconda), and then I wrote a small batch file which looks like this:
set PATH="C:\ProgramData\Anaconda3\lib\site-packages";%PATH%
"C:\ProgramData\Anaconda3\python.exe" "path\to\my\python\script.py"
pause
note that I am manually adding "C:\ProgramData\Anaconda3\lib\site-packages"
to my PATH variable, to ensure that my Anaconda Python distribution will correctly import the necessary modules, including pandas
and numpy
.
But when I run this batch script, the following error happens:
Traceback (most recent call last):
File "path\to\my\python\script.py", line 10, in <module>
import pandas as pd
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
So it looks like Python wasn't able to import numpy
, despite my specific action to add the site-packages
folder to the PATH variable.
How can I solve this issue?
EDIT: my question is quite similar to this one Schedule a Python script via batch on windows (using Anaconda)