Cannot import name _uuid_generate_random in heroku django

akhi1 picture akhi1 · Dec 10, 2015 · Viewed 29.5k times · Source

I am working on a project which scans user gmail inbox and provides a report. I have deployed it in heroku with following specs:

Language: Python 2.7

Framework: Django 1.8

Task scheduler: Celery (Rabbitmq-bigwig for broker url)

Now when heroku execute it the celery is not giving me the output. On Heroku push its showing Collectstatic configuration error. I have tried using whitenoise package

Also tried executing: heroku run python manage.py collectstatic --dry-run --noinput Still getting the same error.

$ heroku run python manage.py collectstatic --noinput gave the following details of the error.

File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/app/salesblocker/__init__.py", line 5, in <module>
from .celery import app as celery_app 
File "/app/salesblocker/celery.py", line 5, in <module>
from celery import Celery
File "/app/.heroku/python/lib/python2.7/site-packages/celery/__init__.py", line 131, in <module>
from celery import five  # noqa
File "/app/.heroku/python/lib/python2.7/site-packages/celery/five.py", line 153, in <module>
from kombu.utils.compat import OrderedDict  # noqa
File "/app/.heroku/python/lib/python2.7/site-packages/kombu/utils/__init__.py", line 19, in <module>
from uuid import UUID, uuid4 as _uuid4, _uuid_generate_random
ImportError: cannot import name _uuid_generate_random

I have also tried to rollback heroku commit to previous working commit and cloned that code but on the next commit(changes:removed a media image from the media folder) its showing the same error again.

Thanks in advance

Answer

Alasdair picture Alasdair · Dec 10, 2015

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.