If you need a simpler and more flexible way to get into the PyCharm debugger, rather than having to have a โplayโ button with one click in PyCharm, you can use the debug server functionality. I used this in situations where running some Python code is not as simple as running python ...
See the Remote Dython Docs Debugging File for Python for more details, but here is a brief description of how this works:
- Download and install the remote debugging helper egg on your server (in OSX they are found under
/Applications/PyCharm.app/Contents/debug-eggs
) - Configuring the remote debug server: click on the configuration menu of the drop-down menu, select
Edit configurations...
, click the +
button, select Python remote debug
.- The details entered here (somewhat vaguely) tell the remote server running the Python script how to connect to your laptop's PyCharm instance.
- set
Local host name
to the IP address of your laptop. - install
port
on any free port that you can use on your laptop (for example, 8888
)
- Now follow the remaining instructions in this dialog: copy-paste the
import
and pydevd.settrace(...)
into your code, in particular where you want your code to โhit a breakpointโ. This is basically the equivalent of PyCharm import pdb; pdb.set_trace()
import pdb; pdb.set_trace()
. Make sure that the changed code is synchronized with your server. - Click the error button (next to the game, this will start the PyCharm debug server) and run the Python script in the same way as you usually did in any user environment, etc. When the breakpoint hits, PyCharm should go into debug mode.
source share