Define PYTHONPATH at the top of your crontab. Defining all of these environment variables (below) can help you avoid some of the common cron problems associated with missing environment variables:
USER=... HOME=/home/... SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin:$HOME/bin PYTHONPATH=... DISPLAY=:0.0 MAILTO=... LANG=en_US.UTF-8
To find the path to MySQLdb, open the python shell and type:
>>> import MySQLdb >>> MySQLdb.__file__ '/usr/lib/pymodules/python2.7/MySQLdb/__init__.pyc'
Your path of mine is different. In the above example, the appropriate dir to add to PYTHONPATH would be /usr/lib/pymodules/python2.7 (although you do not need to add this specific path since your python executable should have this path in its sys.path automatically).
source share