Python from crontab

software development

#1

I have a python script that works great when I execute it manually through SSH. But when I set up a cronjob to run it, I get back this error every time.

ImportError: No module named django.core.management

I’ve tried setting up django via these two methods and got the same error message with each:
http://blog.capstrat.com/tags/crontab/
http://superjared.com/entry/django-and-crontab-best-friends/


#2

Have you tried indicating the full path to the module?

Maximum Cash Discount on any plan with MAXCASH


#3

Bear with me, I’m a Python newb.
the import statement looks like this now:
from django.core.management import setup_environ

how would I change that to include the full path??


#4

Thanks for you help, I just figured it out. I guess crontabs on dreamhost run without environment. I added this to the top of my script

import sys, os
sys.path.append(‘/home/username/django/django_projects’)
sys.path.append(‘/home/username/django/django_src’)

per a comment I found on this Blog:

http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

hope this helps someone!