> OK, I'm getting a different error now: > > Traceback (most recent call last): > File "update_feeds.py", line 58, in ? > update_feeds() > File "update_feeds.py", line 14, in update_feeds > from knoxd.apps.aggregator.models import Feed, FeedItem > ImportError: No module named knoxd.apps.aggregator.models > > I had added the following to my cron: > > export PYTHONPATH=$PYTHONPATH:$HOME/lib/python2.3/site-packages >
(the difference between what the web archive shows and what my emails shows, makes it somewhat hard to keep track of which messages you've already seen, and where we exactly are in the problem solving, but here goes anyway): You initially had your PYTHONPATH set differently: export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/app which is not the same as above. So which one should it be? What does your regular shell have ('printenv PYTHONPATH')? In the off-chance you've already got my other email, did you try that (with the correct PATH settings, whatever those may be)? Ie, setting the variables on the command line, not in the header of the crontab file. >> OK, I did what you instructed and checked the log file, which did >> contain the system path and the traceback about the "can't import >> module...". >> >> I see the paths specified don't contain the path to the feedparser >> module, which explains the error. My question is how do I add this >> path in the cron, especially since the script runs from the command >> line? >> >> On Mar 4, 9:02 am, Evert Rol <[EMAIL PROTECTED]> wrote: >> >>>> Well part of the problem is that the script itself works fine. I >>>> can >>>> run from the command line without a hitch. But when I try to run it >>>> via the cron, I get the traceback about the feedparser module. >> >>> I believe that, because your PYTHONPATH will be set correctly from >>> the >>> command line; but possibly not from a default (basic) shell that >>> cron >>> uses. >>> So, again, try putting those two statements at the top of your >>> script, >>> -before- the 'import feedparser' statement, and let cron do its job. >>> You may need to redirect the output, eg >>> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/ >>> to/ >>> script/update_feeds.log 2>&1 >>> to get that output (I'm not sure how you got the error from the cron >>> job; through email?) >> >>> Check the log file: before the traceback, you should see the >>> result of >>> 'print sys.path'. Check if that includes the correct directories. >> >>>>> Top of script (possibly just below the she-bang): >> >>>>> import sys >>>>> print sys.path >> >>>>>>>> Traceback (most recent call last): >>>>>>>> File "/path/to/script/update_feeds.py", line 10, in ? >>>>>>>> import feedparser >>>>>>>> ImportError: No module named feedparser >> >>>>>>>> And here is the cron: >> >>>>>>>> export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/ >>>>>>>> django/ >>>>>>>> app >>>>>>>> export DJANGO_SETTINGS_MODULE=myproject.settings >>>>>>>> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py >> >>>>>>>> I'm running the cron on my Dreamhost account BTW. >> >>>>>>> Did you try printing out the sys.path at the top of your >>>>>>> script, so >>>>>>> see if the PYTHONPATH is picked up correctly from the cron >>>>>>> environment >>>>>>> settings? I'd guess it should, but it may go wrong there (I'm no >>>>>>> cron >>>>>>> expert). > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---