When I run the command
flower -A main --port=5555
Flower doesn't work, the error is:
> ImportError: cannot import name 'Command' from 'celery.bin.base'
Any ideas? Main is a Django Project
When I run the command
flower -A main --port=5555
Flower doesn't work, the error is:
> ImportError: cannot import name 'Command' from 'celery.bin.base'
Any ideas? Main is a Django Project
Flower is always lagging behind Celery, so if you use the latest Celery (they refactored the CLI) it will probably fail. Stick to 4.4.x until Flower catches up.
One workaround, if you prefer to avoid downgrading your Celery worker, is to run a previous version of Flower separate from your main Celery install. For example, in a container or separate venv. Flower just monitors your broker, and can be run completely separate from your Celery worker.
For your Django/Celery install, run Celery normally (no Flower):
celery -A main worker
For Flower, use docker image mher/flower:0.9.5
, which internally uses Celery 4.4.6, and is reported working.
Here is a sample docker run
command:
docker run --name flower -p 5555:5555 mher/flower:0.9.5 flower --broker=redis://redis-address
Note: You must change the broker address to be your broker's dns-resolvable name or ip. For rabbitmq, use --broker=amqp://guest@rabbitmq-address:5672//
. See the url documentation for advanced options.
Once running, Flower should be available at the Docker host's IP:5555
You can alternatively create a docker-compose file encapsulating all of the arguments in the run command, and use docker-compose up -d
.
If preferred, you can also do all this without Docker, using pip install flower redis celery==4.4.7
, as long as it is separate from your main Celery install, and then run flower with flower --broker=redis://redis-address
. A separate venv may work for this.
See the github issue for future updates on the original bug.
Had same issue while working on celery 5.0.5 so switched to celery 4.4.7 version with flower 0.9.7 and it worked.
You may downgrade Celery as many people have already suggested, or, as in my case, upgrade flower to the last version, which is now 1.0.0 since july 2021 -> https://pypi.org/project/flower/.
I can confirm this last version is compatible with celery[auth,redis,tblib]==5.1.2
.
Personally I'd suggest that you tried to upgrade packages instead of downgrading them, and that upgrading flower has less chances of breaking your project than downgrading celery.
Maybe you can try pip install https://github.com/mher/flower/zipball/master#egg=flower
© 2022 - 2024 — McMap. All rights reserved.
sudo apt install python3-celery
alsopip3 install celery
– Acton