3

I'm using celery as task runner. It's been working fine with Python 2.7. Recently I upgraded my PC to Ubuntu 16.04 and it starts to give met the following error:

from uuid import UUID, uuid4 as _uuid4, _uuid_generate_random
ImportError: cannot import name _uuid_generate_random

Full call stack:

Traceback (most recent call last):
  File "venv/bin/celery", line 7, in <module>
    from celery.__main__ import main
  File "venv/local/lib/python2.7/site-packages/celery/__init__.py", line 133, in <module>
    from celery import five  # noqa
  File "venv/local/lib/python2.7/site-packages/celery/five.py", line 153, in <module>
    from kombu.utils.compat import OrderedDict  # noqa
  File "venv/local/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

This seems rather strange to me. Currently my python version is:

Python 2.7.10

Was there some syntax change within the 2.7.x versions?

3
  • 3
    It looks like you're importing a "private" member (_uuid_generate_random). You probably shouldn't do this as they could change without any notice between versions... Commented May 1, 2016 at 3:26
  • 1
    This isn't a SyntaxError, but an ImportError. So it's probably an issue with trying to import from the library, not with the syntax. Commented May 1, 2016 at 4:06
  • ah. don't I feel silly. Commented May 1, 2016 at 8:48

2 Answers 2

1

_uuid_generate_random has been removed and os.urandom is used instead.

https://hg.python.org/releases/2.7.11/rev/24bdc4940e81

Sign up to request clarification or add additional context in comments.

Comments

1

It's a bug in an old version of kombu. Just upgrade and the error should go away.

pip install -U kombu

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.