Skip to content

Instantly share code, notes, and snippets.

@Joonalai
Forked from AsgerPetersen/readme.md
Last active March 23, 2020 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Joonalai/1a783c3293e7712d33380d16e66a188c to your computer and use it in GitHub Desktop.
Save Joonalai/1a783c3293e7712d33380d16e66a188c to your computer and use it in GitHub Desktop.
PyCharm remote debug of QGIS on OSX

Based heavily on this old guide by TimLinux http://linfiniti.com/2012/09/remote-debugging-qgis-plugins-using-pycharm/

  • In PyCharm click menu "Run -> Edit Configurations" (Or click Edit Configurations in the dropdown in the toolbar)
  • Click the plus to add a new "Python Remote Debug" config
  • Name the config. Use port 53100 (Could probably be any high port)
  • Add to the python code:
import sys
sys.path.append('/home/j/.IntelliJIdea2019.3/config/plugins/python/pydevd-pycharm.egg')
import pydevd
pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True)
  • In PyCharm run the newly made Python Remote Debug configuration. The PyCharm console will print something like
Starting debug server at port 53100
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True)
Waiting for process connection...
  • Now activate/reload your plugin in QGIS.

If everything goes well your PyCharm console will now print

Connected to pydev debugger (build 143.1919.2)

Now PyCharm debugger will break at the line

pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True)

As if it where a regular break point. Continuing from here just use PyCharm break points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment