Cannot import name _uuid_generate_random in heroku django Cannot import name _uuid_generate_random in heroku django python python

Cannot import name _uuid_generate_random in heroku django


You are coming across this issue, which affects Python 2.7.11 (Kombu is required by Celery).

The issue is fixed in Kombu 3.0.30.


While upgrading kombu is the ideal option, if you are stuck with older dependencies that don't allow for this, placing this at the top of my settings.py worked for me:

import uuiduuid._uuid_generate_random = None

This works because _uuid_generate_random was removed here, and this simply restores the default value. This hack seems reasonable as Kombu only checks this to work around a bug resolved in 2007, and if you need this fix because of a recent Python update, you inherently aren't affected :)


Yes, the issue Alasdair mentioned was responsible for the error. I solved the problem in my project by following this workflow to keep only the essential requirements-to-freeze.txt where I list Celery, but not its dependencies like Kombu.

Then, it's enough to upgrade the essential packages and then re-freeze the full list of dependencies with the working Kombu version.

pip install --upgrade -r requirements-to-freeze.txtpip freeze > requirements.txt

And test things to make sure the upgrade didn't break something else ;)