Search code examples
pythonpython-requestscron

Error when using crontab on mac to run python script


I want to run a python script using crontab and I keep running into the same Error Message: ModuleNotFoundError: No module named 'requests'. I'm using the following command on my mac terminal:

15 21 * * * /usr/bin/python3 /Users/username/Python/Filename.py

as I would like to run the Filename Python script every day at 21:15PM. However, I run into this No module named'requests' even though I have the requests module installed within site-packages under /usr/local/lib/python3.9/site-packages

I've also already made sure that crontab has full disc access in System Preferences. Not sure what to do next and would very much appreciate your help.


Solution

  • Posting @Macattack's answer to mark the question as answered:

    try using /usr/local/bin/python3 rather than /usr/bin/python3 or, this might involve setting your PYTHONPATH –