How can I use PyCharm to locally debug a Celery worker?

Shaggy Frog picture Shaggy Frog · May 11, 2016 · Viewed 15.7k times · Source

I have an existing Django project with a virtualenv. After activating the venv, I can run Celery just with the command celery. This works on Windows, OS X and Linux.

I wanted to try PyCharm on Windows, and I'm able to get it to run my Django server (using the project's venv), but I also want to run Celery, so I can debug that as well.

I can't find a simple, straightforward guide to setting up PyCharm so I can debug Celery (in a manner will work with PyCharm on any platform).

Answer

Hrishabh Gupta picture Hrishabh Gupta · Sep 14, 2016

This is what I do to run celery

Go to Edit Configuration, then select the '+' icon to add new Python script and enter the celery path, other parameters and working directory. You can specify environment variables and bottom of that you have the option to select parent environment to include as well. Also, don't forget to choose your python interpreter for taking care of virtual environment.

running celery using pycharm