Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andrey-bublik opened this issue Jan 29, 2014 · 12 comments
Open

Comments

@andrey-bublik
Copy link

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
Copy link

fiee commented Feb 22, 2014

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
Copy link

fiee commented Feb 22, 2014

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
Copy link
Author

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

@gtaylor
Copy link

gtaylor commented May 8, 2014

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
Copy link

htch commented Jan 18, 2015

Still running into this problem, one year later.

@deepvoice
Copy link

Same error here too.

@vladyslav2
Copy link

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
Copy link

Same error here, as well.

@AGovorukha
Copy link

Same error

@voodoonofx
Copy link

Aparently, there's a pull request that solves this that's been waiting to be merged for quite some time.

#22

@ramusus
Copy link

ramusus commented Oct 12, 2015

Same here

$ pip freeze | grep celery
celery==3.1.17
celerymon==1.0.3
django-celery==3.1.16

@AI-Pydev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests