I'm just doing my first steps using Celery. I created a small example which is based on the steps described at http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html When I try to start the worker manually using
celery -A my_example worker --loglevel=info
I run in an error because a module from my virtualenv cannot be found. The virtualenv is activated and the module is installed, so I assume that celery is using my global python interpreter. I checked
celery worker --help
but found no parameter to specify a certain interpreter or virtualenv. Could somebody tell my how to start a worker manually inside a virtualenv?
Update:
I had Celery installed in my global python environment and in my virtualenv. I removed both and double checked that both versions are removed. I then installed Celery i my virutalenv. If I now call the celery
comand line tool, it get the following error:
-bash: /usr/local/bin/celery: No such file or directory
That's the location where the tool would be installed to, if it would be installed globaly. So does Celery work at all from a virtualenv?
To use your virtualenv in production, you will need to add its path to your PYTHONPATH. You will also need to add the directory that contains your settings.py file to the PYTHONPATH, so Django will be able to discover it. Just proceed in a similar manner to do so.
You deploy Celery by running one or more worker processes. These processes connect to the message broker and listen for job requests. The message broker distributes job requests at random to all listening workers.
Tried to cleanly install celery in virtualenv (without installing it in global system interpreter):
mkdir celery-test
cd celery-test
virtualenv-2.7 .python
source .python/bin/activate
pip install celery
celery worker --help
It works perfectly, which celery
gives me:
/home/user/projects/celery-test/.python/bin/celery
As expected.
I suggesting you to rerun your terminal session (possible problems with PATH).
If it does not help, then you can inspect your PATH variable to find, why celery from virtualenv not visible.
And if there are no problems with PATH, but problem persists, try to recreate your virtualenv from scratch.
EDIT:
Another suggestion: check output of:
which celery
It should point to some path, but also it could be aliased like that:
celery: aliased to /somepath/bin/celery
If it actually aliased to something, than you need to check your ~/.bashrc
(~/.zshrc
) or ~/.bash_profile
(~/.zprofile
), or even contents of /etc/profile.d/*
folder. You need to get rid of this alias.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With