celery使用报错记录
celery使用报错记录
1.ImportError: cannot import name 'current_app' from 'celery' (D:\python37\lib\site-packages\celery_init_.py)
PS C:\Users\lcx\Desktop\demo> celery -A celery_task worker -l info -P eventlet
Traceback (most recent call last):
File "D:\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\python37\Scripts\celery.exe\__main__.py", line 7, in <module>
File "D:\python37\lib\site-packages\celery\__main__.py", line 13, in main
maybe_patch_concurrency()
File "D:\python37\lib\site-packages\celery\__init__.py", line 141, in maybe_patch_concurrency
patcher()
File "D:\python37\lib\site-packages\celery\__init__.py", line 104, in _patch_eventlet
eventlet.monkey_patch()
File "D:\python37\lib\site-packages\eventlet\patcher.py", line 280, in monkey_patch
_green_existing_locks()
File "D:\python37\lib\site-packages\eventlet\patcher.py", line 409, in _green_existing_locks
if isinstance(obj, rlock_type):
File "D:\python37\lib\site-packages\celery\local.py", line 94, in __class__
return self._get_class()
File "D:\python37\lib\site-packages\celery\local.py", line 90, in _get_class
return self._get_current_object().__class__
File "D:\python37\lib\site-packages\celery\local.py", line 105, in _get_current_object
return loc(*self.__args, **self.__kwargs)
File "D:\python37\lib\site-packages\celery\local.py", line 398, in getappattr
from celery import current_app
ImportError: cannot import name 'current_app' from 'celery' (D:\python37\lib\site-packages\celery\__init__.py)
图示报错
按照报错找到源代码段
将原导入方法
from celery import current_app 修改为如上图
from celery._state import current_app
继续启动 celery 完美解决
2.AttributeError: 'EntryPoints' object has no attribute 'get'
参考博客,国内访问可能会比较慢
图示
解决办法
原来装的是5.0.0,一运行celery就报错
importlib-metadata降版本
pip install importlib-metadata==4.13.0