'Scheduled task with Python and third party library on Windows 10
This is my first scheduled python task on Windows with a third party library (Pandas). I installed python for all users on the machine so it is at C:\Program Files\Python39. After I pip install pandas it is installed at C:\Users\MyUserName\AppData\Roaming\Python\Python39\site-packages.
Running a simple read_csv and then write_csv works in a batch file, but when I run with a scheduled task (as a service account that doesn't have Pandas installed) it doesn't work. I tried moving the whole site-package directory with pandas in it over to C:\Program Files\Python39 with no luck.
I was finally able to get it to work by adding
import sys
sys.path.append('C:\Program Files\Python39\site-packages')
to the beginning of my script. My two questions are then:
- Why does pip only install a package for the user when python is installed for all users?
- Why isn't the script able to locate pandas without explicitly telling it where to look for it? Is it because the user that the script is running as does not have it in their PATH?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
