For anyone running into this problem who is using a virtual environment:
- Go to
your_project_folder\your_venv\Scripts
and find python.exe
.
- Copy its full path
- Use this as the executable for the "Program/Script" option in Task Scheduler (NOT the standard Python install location which you might have found with
where python
for instance)
This will use the Python instance that contains all your packages to run your code instead of the globally installed version of Python, which may or may not contain them. As a result, it should prevent errors caused by missing packages which can be a common cause of the (0x1)
error.
An alternative solution would be to install all of your required packages globally on your machine, though in general, this isn't a great practice.
NOTE: There can be other causes of the (0x1)
error, such as if you have bugs in your code, but if all is smooth there and you couldn't get your script to run from the Task Scheduler, this should solve it for you.
Hope this helps!