Skip to content
Advertisement

Trouble running Python script CRON: Import Error: No Module Named Tweepy

Background: I am following Crontab not running my python script in an attempt to debug and run my python script using CRON. Per SO suggestions, I tried /usr/bin/python /Users/eer/Desktop/myscript.py on the terminal.

Problem: However, I get a an error: ImportError: No module named tweepy. So, I tried to pip install tweepy and I get the following:Requirement already satisfied: tweepy in /Users/eer/anaconda/lib/python2.7/site-packages . So it seems I have tweepy but when I /usr/bin/python /Users/eer/Desktop/myscript.py it doesn’t seem to read it. Suggestions?

Advertisement

Answer

Your /usr/bin/python MyScript.py command and your pip command are invoking two different python interpreters. Try either:

/Users/eer/anaconda/bin/python MyScript.py

or

/usr/bin/pip install tweepy

The former will invoke your personal Python interpreter, the one that already has tweepy installed. The latter will install tweepy for the system-wide Python.

You may need to invoke the latter option as root, for example, sudo /usr/bin/pip install tweepy.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement