Check out PyCharm. I've been a happy paying customer for years, however a free community edition is also available.
There is a file watcher plugin that will copy files over to a remote machine (your RPi). And it has the ability to perform remote debugging.
wire up debugging modules
With respect to setting up PyCharm remote debugging, first thing to do is wire up pycharm-debug.egg
. I'm on a Mac and in my case the file is at /Applications/PyCharm.app/Contents/debug-eggs/pycharm-debug.egg
. I copied it over to my RPi with the command:
scp /Applications/PyCharm.app/Contents/debug-eggs/pycharm-debug.egg pi@mediapi:
This file needs to be somewhere in Python's path in order for it to be found. I looked for a suitable place by running the following:
pi@mediapi ~ $ python -c 'import sys; print sys.path'
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7']
From that list I believe /usr/local/lib/python2.7/dist-packages/
is most suitable (because it's in /usr/local
), so:
sudo mv pycharm-debug.egg /usr/local/lib/python2.7/dist-packages/
And we need a .pth
file to inject it into the path:
pi@mediapi ~ $ echo /usr/local/lib/python2.7/dist-packages/pycharm-debug.egg | sudo tee -a /usr/local/lib/python2.7/dist-packages/pycharm-debug.pth
Finaly, verify the setup:
pi@mediapi ~ $ python -c 'import pydevd; print pydevd'
<module 'pydevd' from '/usr/local/lib/python2.7/dist-packages/pycharm-debug.egg/pydevd.py'>
Cool, the debugging modules are wired in. On to debugging a script. I'm going to debug the listener script I wrote for this post.
PyCharm setup
In PyCharm, go to Run -> Edit Configurations...
Hit the +
sign on the top left and select Python Remote Debug
. Simply give it a name, remote debug
and you're done here; hit ok.

Now click on Run -> Debug 'remote debug'
and you'll see a message in the debug console, Use the following code to connect to the debugger
Copy the lines, in my case they ended up looking like this:
import pydevd
pydevd.settrace('localhost', port=56112, stdoutToServer=True, stderrToServer=True)
Paste them at the top of the file you're debugging and save the file.
Without using the file sync plugin I copy the files using rsync:
[berto@g6]$ rsync -av ./ pi@mediapi:broadcast/
Now, notice the configuration says localhost
. The best way to go about wiring up the debugger is using SSH's port forwarding capabilities so that the RPi can be on your desk or around the globe and it works the same way. SSH into the RPi using this command to link the remote port to the local port:
[berto@g6]$ ssh -R 56112:localhost:56112 pi@mediapi
PyCharm should show you a message Waiting for process connection...

On the RPi, run the program and you'll see the debugger kick in. By default it pauses on the line right after the pydevd line, which you can change in the config if you wish.
And at that point you're remotely debugging! :)
