Monday, October 8, 2012
celery + djcelery problem with virtualenv and virtualenvwrapper
this is a tricky one - out of nowhere, production env boxes started failing at celery startup with:
ImportError: cannot import name current_app
when importing djcelery. Versions of celery were fine.
It turns out if you import celery and run
import celery.current_app you'll see the real problem, which is that the virtualenv binary is out of sync with the new python binary from a recent security update - specifically, os.urandom has been changed/removed.
if you have virtualenvwrapper, and you let $ENV=YOUR_ENVIRONEMNT_NAME
So the answer is:
deactivate (in case an env is running)
cd ~/$ENV_HOME (.virtualenvs, for me)
this will rebuild your python binary with the correct python post-security fix, without losing any other packages. happy hacking!