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

Viewed 11096

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?

3 Answers

In Linux/Unix environment, cronjob usually runs with root privilege. You can check using the following command

ps -eF | grep cron

When installing tweepy, you might have installed as the normal user. Install tweepy as root and it should work.

sudo /usr/bin/pip3 install tweepy
Related