Skip to content
Advertisement

in Celery/Django : cannot find reference ‘control’ in celery.task.control

I’m trying to use celery in my project. when I use from celery.task.control import revoke the PyCharm highlight control and warn me cannot find reference 'control' in __init__.py and also PyCharm adds broken line under revoke and warn me Unresolved reference revoke.

But when I run the project, celery is working great without any problem with calling tasks or revoking them. My question is why PyCharm warns me and is it possible in future any problem happen about that?

celery.py:

JavaScript

project/__init__.py:

JavaScript

Advertisement

Answer

This typically happens when you use one Python virtual environment (or just local Python) in your PyCharm, and another Python environment for your Celery worker. If you properly install Celery in the environment used by PyCharm you will not see that warning.

As long as the environment where you want to run your Celery worker in has Celery properly installed you will be fine, and you may ignore the PyCharm warning, but I recommend you install Celery in your PyCharm project’s environment too to enjoy the benefits of PyCharm code analysis, etc…

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement