#🔒 My cron job for my Python script on MacOS is not running because of ModuleNotFoundErrors shown

4 messages · Page 1 of 1 (latest)

trail goblet
#

Here’s my cron job:

* * * * * python3 /Users/annanguyen/Documents/Anna_Projects/Web_Scraping_Python_projects/Gas_Price_Code.py > /Users/annanguyen/Documents/Anna_Projects/Web_Scraping_Python_projects/Gas_Price_backup_logs/backup.log 2>&1

And here’s the errors I got from my backup log:

Traceback (most recent call last): File "/Users/annanguyen/Documents/Anna_Projects/Web_Scraping_Python_projects/Gas_Price_Code.py", line 1, in <module> import requests ModuleNotFoundError: No module named 'requests'

I checked on Mac Terminal and confirmed that the requests package is already installed here:

Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2.32.3)

In PyCharm, my Python interpreter has that same exact path as the one above shown in Terminal, and my Python interpreter already has requests package as well. I ran the script manually and it works fine. So I’m not sure what did I do wrong?

autumn remnantBOT
#

@trail goblet

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

autumn remnantBOT
#

@trail goblet

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.