auvipy / celery-flower

Under heavy development now: Real time Celery monitoring with ASGI 3.0 +
BSD 3-Clause "New" or "Revised" License
176 stars 36 forks source link

Cannot import name state: from celery.events.state import state #24

Open andrey-bublik opened 10 years ago

andrey-bublik commented 10 years ago

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:

  1. Celery sources
/usr/local/lib/python2.7/dist-packages/celery/events/state.py:
...
class State(object):
"""Records clusters state."""
...
  1. 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)
fiee commented 10 years ago

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,

fiee commented 10 years ago

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.)

andrey-bublik commented 10 years ago

Unfortunately, for me this problem was solved only after downgrading celery to version 3.0.

gtaylor commented 10 years ago

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()).

htch commented 9 years ago

Still running into this problem, one year later.

deepvoice commented 9 years ago

Same error here too.

vladyslav2 commented 9 years ago

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

ajferrick commented 9 years ago

Same error here, as well.

AGovorukha commented 9 years ago

Same error

voodoonofx commented 9 years ago

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

ramusus commented 9 years ago

Same here

$ pip freeze | grep celery
celery==3.1.17
celerymon==1.0.3
django-celery==3.1.16
AI-Pydev commented 6 years ago

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