celery-flower
celery-flower copied to clipboard
Cannot import name state: from celery.events.state import state
I got this when trying to run celerymon:
# /usr/local/bin/celerymon
Traceback (most recent call last):
File "/usr/local/bin/celerymon", line 9, in <module>
load_entry_point('celerymon==1.0.3', 'console_scripts', 'celerymon')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2279, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python2.7/dist-packages/celerymon/bin/celerymon.py", line 44, in <module>
from ..service import MonitorService
File "/usr/local/lib/python2.7/dist-packages/celerymon/service.py", line 3, in <module>
from .consumer import EventConsumer
File "/usr/local/lib/python2.7/dist-packages/celerymon/consumer.py", line 4, in <module>
from celery.events.state import state
ImportError: cannot import name state
Problem is pretty simple:
- Celery sources
/usr/local/lib/python2.7/dist-packages/celery/events/state.py:
...
class State(object):
"""Records clusters state."""
...
- And celerymon sources:
/usr/local/lib/python2.7/dist-packages/celerymon/consumer.py:
...
from celery.events.state import state
...
Obviously, need to import State instead of state - or vice versa? Can anybody comment on, confirm such bug and help to solve?
Ubuntu 11.10
# celery --version
/usr/local/lib/python2.7/dist-packages/celery/bin/base.py:149: UserWarning: Cannot load extension 'celerymon.bin.celerymon:MonitorDelegate': ImportError('cannot import name state',)
'Cannot load extension {0!r}: {1!r}'.format(sym, exc))
3.1.0 (Cipater)
celerymon - Real-time monitoring of Celery workers.
INSTALLED: 1.0.3 (latest)
I get the same. Thanks for your analysis!
I tried class state(State): pass
in celery/events/state.py
but get "AttributeError: type object 'MonitorDelegate' has no attribute 'leaf'" from bin/celery.py
.
The import error stays if I change from celery.events.state import State as state
in celerymon/consumer.py
,
Issue #22 tries to fix this, seems the State
object is something different than state
.
(Sorry, didn’t check earlier, found this thread here via Google.)
Unfortunately, for me this problem was solved only after downgrading celery to version 3.0.
I'm seeing this with celery 3.1 when running any of the celery commands (beat, worker, etc). Also have django-celery installed, but am using the new API (without djcelery.setup_loader()).
Still running into this problem, one year later.
Same error here too.
Same error here, after update celery and django-celery to: celery==3.1.17 celery-with-redis==3.0 celerymon==1.0.3 django-celery==3.1.16
Same error here, as well.
Same error
Aparently, there's a pull request that solves this that's been waiting to be merged for quite some time.
https://github.com/celery/celerymon/pull/22
Same here
$ pip freeze | grep celery
celery==3.1.17
celerymon==1.0.3
django-celery==3.1.16
Update import statement from "from celery.events.state import state" to "from celery.events.state import State as state" in the below files. /usr/local/lib/python2.7/dist-packages/celerymon/handlers/api.py /usr/local/lib/python2.7/dist-packages/celerymon/consumer.py