我正在使用芹菜作为任务运行程序。它在Python 2.7中运行良好。最近我把我的电脑升级到Ubuntu 16.04,它开始出现以下错误:
from uuid import UUID, uuid4 as _uuid4, _uuid_generate_random
ImportError: cannot import name _uuid_generate_random
完整调用堆栈:
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
这对我来说似乎很奇怪。目前我的python版本是:
Python 2.7.10
2.7.x版本中是否有语法更改?
_uuid_generate_random
已删除,而使用os.urandom
。
https://hg.python.org/releases/2.7.11/rev/24bdc4940e81
这是kombu旧版本中的一个错误。只要升级,错误就会消失。
pip install -U kombu