Cannot start Celery Worker (Kombu.asynchronous.timer)

与世无争的帅哥 提交于 2019-12-22 05:38:28

问题


I followed the first steps with Celery (Django) and trying to run a heavy process in the background. I have RabbitMQ server installed. However, when I try, celery -A my_app worker -l info it throws the following error

File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\anaconda3\lib\site-packages\celery\concurrency\prefork.py", line 
18, in <module>
from celery.concurrency.base import BasePool
File "c:\anaconda3\lib\site-packages\celery\concurrency\base.py", line 15, 
in <module>
from celery.utils import timer2
File "c:\anaconda3\lib\site-packages\celery\utils\timer2.py", line 16, in 
<module>
from kombu.asynchronous.timer import Entry
ModuleNotFoundError: No module named 'kombu.asynchronous.timer'

I've searched a lot, but can't seem to get it working. Any help will be highly appreciated. Thank you!


回答1:


I have the same problem, but solved it when reinstall celery with version 3.1.25

pip uninstall celery && pip install celery==3.1.25

Maybe because windows is not officially supported by celery 4, https://github.com/celery/celery/issues/3551




回答2:


TL;DR: remove the kombu directory from the root of your virtualenv (if it exists). It may only fail on Windows.

It seems to be a quirk. I found the same error and I checked out what was happening.

The wheel package that pip downloads looks fine (kombu.asynchronous.timer exists in it). The release for the last version (currently 4.2.0) also is fine. What was strange is what I found in my virtualenv installation.

I found a kombu directory at my virtualenv root which has the content of the library but it also has an "async" directory, alongside an "asynchronous" one. These directories aren't from the 4.2.0 release, as async has the timer.py file but asynchronous doesn't.

From where did it come? It appears that from the wheel's data directory.

So, the solution: I removed the kombu directory from the root of my virtualenv and celery worked.




回答3:


I tested celery on the same python version you have and it is okay. and also https://github.com/celery/kombu/blob/master/kombu/asynchronous/timer.py shows that renaming things randomly is not going to help you. Maybe you should try pip uninstall kombu && pip --no-cache-dir install -U kombu to perform a fresh install for kombu. I guess there must be something wrong with your installation. so if the kombu reinstall thing didn't work, try installing the whole thing again.




回答4:


I just started with Celery. I followed instructions and installed Celery v 4.2.0

when I was trying to run the command : celery -A mysite worker -l info I got the error :

ModuleNotFoundError: No module named 'kombu.asynchronous.timer

I removed Celery installation : pip uninstall celery

Afterwards installed Celery 3.1.25 as 'chuhy' recommended

but..It had some other issues, so I immediately un-installed 3.1.25 , and reinstalled celery v4.2.0 .

After this scenario the error didn't pop again.




回答5:


I work on Windows so I had a bit of problem with this. But my solution was to create new conda env with python 3.6.8 ( as i have understand celery may work on python 3.7 but have lot of problems). Then proceed to install latest versions of celery(4.3.0) and Django(2.2.3) and after that everything worked fine.




回答6:


I had this issue with the default Celery installation from pip (3.1.26Post2). As mentionned above, I installed instead version 3.1.25, but Celery was still not working. Thus I explicitly installed the latest version:

pip install Celery==4.3

and everything is working now!



来源:https://stackoverflow.com/questions/50511905/cannot-start-celery-worker-kombu-asynchronous-timer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!