Reputation: 31
I'm new to celery and python in general and wanted to use celery to have an async task in the application. While I tried to see how it works, a demo app itself was not working on my local setup. I started rabbitmq server locally on the system with default config: user: guest, password: guest and on default port 5672.
I picked the sample code from http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html
from celery import Celery
app = Celery('tasks', broker='amqp://guest:guest@localhost:5672/hello')
@app.task
def add(x, y):
return x + y
All these were done and are placed inside of a virtualenv. Then I am in the folder location containing the app.py file and use the command: celery -A tasks worker --loglevel=info to run the celery worker from the terminal. Getting following output after executing the command:
Traceback (most recent call last):
File "/usr/local/bin/celery", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/celery/__main__.py", line 13, in main
from celery.bin.celery import main as _main
File "/Library/Python/2.7/site-packages/celery/bin/__init__.py", line 2, in <module>
from .base import Option
File "/Library/Python/2.7/site-packages/celery/bin/base.py", line 17, in <module>
from celery import VERSION_BANNER, Celery, maybe_patch_concurrency
File "/Library/Python/2.7/site-packages/celery/local.py", line 509, in __getattr__
module = __import__(self._object_origins[name], None, None, [name])
File "/Library/Python/2.7/site-packages/celery/app/__init__.py", line 5, in <module>
from celery import _state
File "/Library/Python/2.7/site-packages/celery/_state.py", line 15, in <module>
from celery.utils.threads import LocalStack
File "/Library/Python/2.7/site-packages/celery/utils/__init__.py", line 9, in <module>
from .functional import memoize # noqa
File "/Library/Python/2.7/site-packages/celery/utils/functional.py", line 11, in <module>
from kombu.utils.functional import (
ImportError: cannot import name LRUCache
Dependencies used: amqp 2.2.2, billiard 3.5.0.3, celery 4.1.0, kombu 4.1.0, python 3.6
Let me know the mistake and if any other details required
Upvotes: 3
Views: 3809
Reputation: 160
The current command to run your celery worker will be:
celery -A app worker --loglevel=info
Provided your worker file is called app.py
Upvotes: 1
Reputation: 935
Try installing the dev version of Billiard and Kombu:
pip install -e git+https://github.com/celery/billiard.git#egg=billiard
pip install -e git+https://github.com/celery/kombu.git#egg=kombu
Upvotes: 0
Reputation: 405
Try this:
app = Celery('tasks', broker='pyamqp://guest@localhost:5672/')
Also (even if I don't think it's related to you error) you're saying that you use python 3.6 but on error trace it look like it is version 2.7.
Upvotes: 0