3

I'm using Django-Cron to schedule some database stuff. But after I edited my crontab like so:

*/1 * * * * /Users/apple/Documents/Django/pricecompare/manage.py    runcrons >> /Users/apple/Documents/Django/pricecompare/app/log.txt"

I'm getting this error sent as "mail":

 "Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?"

I'm not using any virtual environment by the way.

However, when I run the same script directly in the terminal, I don't get any error. I can import Django in the terminal as well.

Any solutions? I'm using python 2. and I might have copied the code that was supposed to be used in python 3, so I suspect that might be giving me the error.

Prakhar Trivedi
  • 8,218
  • 3
  • 28
  • 35
  • Maybe: `*/1 * * * * /path/to/python /Users/apple/Documents/Django/pricecompare/manage.py` – allcaps Mar 03 '17 at 07:19
  • When you run in terminal, it is running by the user you logined.But in crontab may be it is executed by root.So take a look at http://stackoverflow.com/questions/1601153/django-custom-command-and-cron – itzMEonTV Mar 03 '17 at 07:59
  • @ShubhamNamdeo Which code should I upload? – siddharth iyer Mar 03 '17 at 10:35
  • @itzmeontv I have tried all the fixes suggested in the link. I got this error: /Users/apple/Documents/Django/pricecompare/cronscript.sh: line 1: export: `=': not a valid identifier /Users/apple/Documents/Django/pricecompare/cronscript.sh: line 1: export: `pricecompare.settings': not a valid identifier /Users/apple/Documents/Django/pricecompare/cronscript.sh: line 2: ./manage.py: No such file or directory – siddharth iyer Mar 03 '17 at 10:44

0 Answers0