2

I have a python script that runs fine when I am executing it from within a virtualenv but fails with the error "ImportError no module named oauthlib.oauth2..." I believe that the cron job needs to activate the virtual environment or that it is somehow related. I have tried many suggestions found on this site but without success. I am missing something and it's probably trivial. The cron job runs as root and the code is under a different user. I am not sure how to solve this. Your help is truly appreciated.

Leo
  • 69
  • 5

1 Answers1

2

You can use the python that is in your virtualenv like so:

/srv/.virtual/wl/bin/python /home/myusername/projects/wl01/wl_cron.py >> /tmp/cron_output 2>&1

Sources and References:

Cron and virtualenv

Steampunkery
  • 3,839
  • 2
  • 19
  • 28