I keep on getting the following error when testing a simple celery example.
AttributeError: 'EntryPoints' object has no attribute 'get'
using the following CLI command:
celery -A ctest worker --loglevel=INFO
The versions of the main modules I used are the following. (versions extracted from requirements.txt):
- celery==5.2.7
- importlib-metadata==4.13.0
- kombu==5.2.4
And the Python version I used is 3.12
I have tried the solutions provided to this issue from links such as
Fixed the version of celery as suggested. I was expecting this to resolve the issue but it did not.
pip install celery==5.2.3
Has anybody come across this issue? Any suggestions on how to resolve it?
For your information, I have tracked the errors and fixed the source files' relevant lines by passing the group="value" argument where value is namespace .. etc to the entry_point method and this seems to resolve the issue, but I do not believe this is the correct way to resolve the issue. Following are the steps I took to modify the respective files.
1- FIX ONE
ERROR
File "/home/../.envs/.zppEnv/lib/python3.12/site-packages/kombu/utils/compat.py", line 82, in entrypoints
for ep in importlib_metadata.entry_points().get(namespace, [])
SOLUTION
I modified line 82 in the ..../compat.py file and changed it from
for ep in importlib_metadata.entry_points().get(namespace, [])
to
for ep in importlib_metadata.entry_points(group ='namespace') #.get(namespace, [])
2- FIX TWO
ERROR
File "/home/../.envs/.zppEnv/lib/python3.12/site-packages/celery/bin/celery.py", line 79, in <module>
@with_plugins(entry_points().get('celery.commands', [])
SOLUTION
I modified line 79 in the .. bin/celery.py and changed the error line of the decorator from
@with_plugins(entry_points().get('celery.commands', [])
to
@with_plugins(entry_points(group = 'celery.commands') #.get('celery.commands', [])
3- FIX THREE:
ERROR
File "/home/../.envs/.zppEnv/lib/python3.12/site-packages/celery/utils/imports.py", line 146, in load_extension_class_names
for ep in entry_points().get().get(namespace, []):
SOLUTION
I amended the error line to the following as is the case for FIX ONE above
for ep in importlib_metadata.entry_points(group ='namespace') #.get(namespace, [])
The above three fixes seem to have resolved the issue and celery started running.
-------------- [queues]
.> celery exchange=celery(direct) key=celery
I am sure the above solution is not right for all sorts of reasons, please if there is something obvious I am missing let me know. I am a new starter in this area and maybe I am making the starters error.
Thank you in advance for your help.
I had this same issue with Python 3.12 and Celery
5.2.6. It looks like the first version of Celery to support Python 3.12 is5.3.5(which was not released when the question was first posted).Installing Celery
>5.3.5fixed the issue for me.