Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging options w/ Python, Flask and Sublime Text 2

I have just switched to Sublime Text 2 for my Python development. I usually do web programming with the Flask micro framework.

What are my debugging options with this combination, and how do I set it up? I'm working on Windows 7.

like image 352
happygoat Avatar asked Nov 01 '12 09:11

happygoat


People also ask

Can we debug Python code in Sublime Text?

Use ctrl+shift+b to toggle breakpoint in a line Show activity on this post. You could try to use an IDE specific for Python which makes debugging and setting up python projects really easy. I would recommend you try the free community version of Pycharm.

How do you debug a flask in Python?

As of Flask 2.2, to run in debug mode, pass the --app and --debug options to the flask command. If you're using the app. run() method instead of the flask run command, pass debug=True to enable debug mode. Tracebacks are also printed to the terminal running the server, regardless of development mode.

Can you debug in Sublime Text?

Java Prime Pack Debugging is the process of finding errors and bugs in the given code and fixing them. Sublime editor includes various plugins that have debugging features, which helps in finding errors easily. It is an extension used for debugging the PHP files and scripts.


1 Answers

Use pdb:

import pdb; pdb.set_trace()

(or the even better pdb++)

Also, Flask already include Werkzeug which contains an interactive JavaScript based in-browser debugger, I highly recommend you utilize it.

(if your Flask uses uWSGI you can check out this guide to make Werkzeug debugger work: debugging flask application under uWSGI)

like image 181
K Z Avatar answered Oct 10 '22 09:10

K Z