Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HOW TO use Pycharm to debug python script?

Tags:

I'm trying to use pycharm. I can write code and run it. However, I do not know how to to debug the code. When I click the debug button, I get something similar to the below image:

enter image description here

Is there any special configuration needed for debugging in pycharm? Here is my configuration:

enter image description here

like image 526
hakunami Avatar asked Apr 20 '12 03:04

hakunami


People also ask

How do I debug a python script?

Starting Python Debugger To start debugging within the program just insert import pdb, pdb. set_trace() commands. Run your script normally, and execution will stop where we have introduced a breakpoint. So basically we are hard coding a breakpoint on a line below where we call set_trace().

Does PyCharm have a debugger?

The debugger is attached behind the scenes, so you don't have to configure anything specific to start a debugger session. If you are able to run your program from PyCharm, you will also be able to debug it using the same configuration.


1 Answers

I'd like to illustrate how to set parameters, as it took me a while to do this right:

Find the drop-down menu next to the "Run" button:
enter image description here

Choose the file you want to configure, then click "Edit Configurations":
enter image description here

Add script parameters:
enter image description here

like image 143
laike9m Avatar answered Sep 16 '22 20:09

laike9m