2

I am working with creating plugins for QGIS 2.4.0 (Chugiak). I am curious to know how I can write the codes, and debug them in the environment I am comfortable in, i.e. PyCharm Community Edition 3.4.1.

I am looking for a step wise methodology of how to set up PyCharm to read the debug scripts formulated in PyQGIS syntax.

3

The community edition doesn't support remote debugging, meaning you can't test your plugin while running in QGIS.

You can use Winpdb (cross platform despite the name) to remotely debug a QGIS plugin. See: http://winpdb.org/

From the PyQGIS Programmers Guide (http://locatepress.com/ppg):

In your code, add lines to enable debugging:

import rpdb2
rpdb2.start_embedded_debugger(password)

When your code encounters the start_embedded_debugger statement, it will pause and wait five minutes for a debugger to attach. From Winpdb you then attach to the process using the same password specified in your code. From that point on you have access to the code within the debugger.

  • Thank you very much.. Would it be possible for you (to edit your answer) to share a link that shows how to establish that remote debugger? That would solve the question completely... – Akhil Oct 28 '14 at 3:47
0

I was able to debug with winpdb my plugin in qgis. Here are steps I took (MacOS):

  • I downloaded windpdb: https://code.google.com/archive/p/winpdb/downloads
  • I unzipped it and install it (there is a README file there with instruction how to do it, but it was just one command sudo python setup.py install -f)
  • Then I needed to prepare qgis:
    • In qgis go to Plugins -> Manage and Install Plugins -> Settings
    • Checked option "Show also experimental plugins"
    • Then searched for "Remote Debug" plugin and install it

When I had it installed, I clicked on debug plugin icon (it looked like a bug). Then the plugin's window shown and there are further instruction how to connect winpdb with qgis.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.