I have a python file which executes perfectly in shell environment, however when I try to implement it from the crontab, it doesn't execute at all..
The following code is what I run in the crontab:
* * * * * /usr/bin/python3 /home/maestro/Desktop/Check_monitors.py >> /home/maestro/Desktop/text.txt 2>&1
I am 99% percent sure the code in crontab is correct. I have also checked which python version is being used in the shell and it is 3.6, located at /usr/bin/python3.
The error message printed out from the cron job is as follows:
Traceback (most recent call last):
File "/home/maestro/Desktop/Check_monitors.py", line 7, in <module>
import pandas
File "/usr/local/lib/python3.6/dist-packages/pandas/__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
dateutil: No module named 'dateutil' ```
Obviously I tried the default to install the module as follows:
pip3 install python-dateutil
Resulting in:Requirement already satisfied: python-dateutil in ./.local/lib/python3.6/site-packages Requirement already satisfied: six>=1.5 in ./.local/lib/python3.6/site-packages (from python-dateutil)
Which does seem logical as I am able to run it from the shell. It must have something to do with dateutils within cron but I am not able to figure out how to solve it.
I did find some more information on the error here: https://bugs.launchpad.net/python-crontab/+bug/1167180 but am not sure how this could lead to a solution. All help would be appreciated.