I am using crontab to run a python script that requires the module MySQLdb. When I run this script from the command line everything works fine. However, trying to run it usi
It may be that you're using a different Python executable. On the shell, enter which python
to find out where the Python executable is located. Let's say this returns something other than /usr/bin/python
, say /home/myuser/bin/python
, then in the first line of your script, you would write:
#!/home/myuser/bin/python
It may also be that your shell has environment variable called PYTHONPATH
. If that's the case and you find where it's importing the library from, then this is how you would add the path to find the library in the first line of your script, before the import of "MySQLdb":
import sys; sys.path.append('/path/to/MySQLdb-lib/')