Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crontab | Missing Python Module

Tags:

People also ask

What is Python crontab?

The crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list. cron is the system process that will automatically perform tasks for you according to a set schedule.

How do I install missing imports in Python?

try: import foo except ImportError: sys. exit("""You need foo! install it from http://pypi.python.org/pypi/foo or run pip install foo.""")


I'm very new to Unix and crontab. The only major issue I'm running into is pointing terminal to the python modules for the specific program I'm trying to run. From command line the program runs fine but won't from crontab.

The first cronjob sends me an email saying that the cronjob is running. The second(createUpdate) runs a script I've built, set to run each minute.

crontab -l returns:

*/1 * * * * python /Users/JohnDoe/Desktop/emailalert.py
*/1 * * * * PYTHONPATH =/Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages; export PYTHONPATH; python /Users/JohnDoe/Desktop/createUpdate.py 

Am I structuring PYTHONPATH correctly?

Should I break it out before the cron?

Is 'export PYTHONPATH' necessary?

EDIT I forgot to add the error

/bin/sh: PYTHONPATH: command not found
Traceback (most recent call last):
  File "/Users/JohnDoe/Desktop/createUpdate.py", line 1, in <module>
    import beatbox
ImportError: No module named beatbox