Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'module' object has no attribute 'celery'

I am following the Celery Documentation v:latest I installed all the dependencies and my celery version is 3.0.11 I made a file tasks.py and pasted the code:

from celery import Celery

app = Celery('tasks', broker='amqp://guest@localhost//')

@app.task
def add(x, y):
    return x + y

When I run the very Next command in the same directory:

celery -A tasks worker --loglevel=info

I get this error `AttributeError: 'module' object has no attribute 'celery'

I got few similar question but that did not helped me ... Do any one has any idea ? Here is the TraceBack...

Traceback (most recent call last):
  File "/home/nishant-un/env/bin/celery", line 9, in <module>
    load_entry_point('celery==3.0.11', 'console_scripts', 'celery')()
  File "/home/nishant-un/env/local/lib/python2.7/site-packages/celery/__main__.py", line 14, in main
    main()
  File "/home/nishant-un/env/local/lib/python2.7/site-packages/celery/bin/celery.py", line 946, in main
    cmd.execute_from_commandline(argv)
  File "/home/nishant-un/env/local/lib/python2.7/site-packages/celery/bin/celery.py", line 890, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/home/nishant-un/env/local/lib/python2.7/site-packages/celery/bin/base.py", line 177, in execute_from_commandline
    argv = self.setup_app_from_commandline(argv)
  File "/home/nishant-un/env/local/lib/python2.7/site-packages/celery/bin/base.py", line 295, in setup_app_from_commandline
    self.app = self.find_app(app)
  File "/home/nishant-un/env/local/lib/python2.7/site-packages/celery/bin/base.py", line 313, in find_app
    return sym.celery
AttributeError: 'module' object has no attribute 'celery'
like image 456
Nishant Kashyap Avatar asked Nov 17 '13 10:11

Nishant Kashyap


1 Answers

Running the following command from the root of my project, fixed this issue:

celery -A my_app.tasks worker --loglevel=info

Celery needed the path to the tasks.py file.

like image 191
raratiru Avatar answered Oct 04 '22 17:10

raratiru