Using a virtualenv in a scheduled task

If you want to run a scheduled task in a virtualenv, specify the full path to the virtualenv python inside your task's command-line.

So, eg, instead of:

/home/myusername/myproject/mytask.py

Use

/home/myusername/.virtualenvs/myvenv/bin/python /home/myusername/myproject/mytask.py

If you need to make sure there's only one copy of your task running at a time, see the long-running tasks article