I have created a custom CLI command in Flask, that I am able to run via flask my_command
in the terminal. I want to run this command using PyCharm's debugger.
I created a "Flask server" configuration, and running it with the PyCharm debugger stops at breakpoints I set inside view functions. But if I try to run my CLI command from PyCharm's terminal, it doesn't stop at breakpoints in the command.
Do I need a custom configuration to debug custom CLI commands? I found a question about Django commands, but PyCharm's "Flask server" configuration doesn't have the same options. How can I configure PyCharm to debug a Flask CLI command?
Run/Debug Configuration: Flask Server Professional feature: download PyCharm Professional to try. Use this dialog to create run/debug configuration for Flask server and customize the way PyCharm executes your Flask application. See Creating web applications with Flask for more details on using Flask in PyCharm.
Creating a Flask application in PyCharmSelect Flask in the New Project dialog. In the Location field, provide the path to the project location and type the MeteoMaster as the project name. Leave the rest of the settings default and save the changes. Click Shift+F10 to run the default application.
PyCharm's "Flask server" configuration only calls the flask run
command, it doesn't provide a way to call other commands. To do that, create a regular "Python" configuration that runs the flask
command with the arguments you want.
flask
.my_command --option A
.FLASK_APP=my_app
and FLASK_ENV=development
, the same way you'd use them from the terminal.
Running this configuration with the debugger will stop at breakpoints in your CLI command instead of running the server.
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