2

having trouble with debuging QyPython plugins from Eclipse: - Win 7 x64 - QGIS 2.7 - Eclipse Luna with PyDev installed

  1. Tried to debug using Remote Debugger (http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/ide_debugging.html) Remote Debbuer displays "Debug Connection Failed"

  2. Tried to debug using settrace() as it is explained here: http://linfiniti.com/2011/12/remote-debugging-qgis-python-plugins-with-pydev/ Few days this approach working fine but today when I started QGIS desktop - desktop hangs on Startup Popup with "Restoring loaded plugin" status. I.e. the break point in my plugn is not hit. If I remove settracte() from code - QGIS is started OK. Looks like some break in link between QGIS and PyDev Debug Server.

I'm using Simple Test Plugin created by plugin builder. Here is the code for setrace()

import sys
sys.path.append("C:/eclipse/plugins/org.python.pydev_3.9.2.201502050007/pysrc")
from pydevd import *

FORM_CLASS, _ = uic.loadUiType(os.path.join(
    os.path.dirname(__file__), 'Test_dialog_base.ui'))


class TestDialog(QtGui.QDialog, FORM_CLASS):
    def __init__(self, parent=None):
        """Constructor."""
        super(TestDialog, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        settrace()
        self.setupUi(self)

How do I fix this?

Windows restart does not help. Deleting .qgis2 folder does not help either.

2

I suggest you to add "C:/eclipse/plugins/org.python.pydev_3.9.2.201502050007/pysrc" to the pythonpath in Settings->Options->System->Envoronment".

sys.path.append("C:/eclipse/plugins/org.python.pydev_3.9.2.201502050007/pysrc")

and then call in the python console:

from pydevd import * settrace(port=5678, suspend=False)

in this way you don't have to setup the pydev connection during init of the plugin. This is executed loading first time the plugin module => hang qgis if connection is not available

In the above way, you can activate connection when you want. These steps will be available inside Remote Debug Plugin in the next release:

https://github.com/sourcepole/qgis-remote-debug/issues/6

Now the this debug plugin use a local pydevd implementation that have to be aligned with that installed in your eclipse. so many times it does not work.

I don't know if it's polite or not, but more details will be in "Mastering QGIS" packt book available soon:

https://www.packtpub.com/application-development/mastering-qgis

  • Thanks Luigi! Finally I was able to enable debug back by using settrace(port=5678, suspend=False) and (!!!) after re-installing PyDev plugin :) – Egor.Baykov Mar 2 '15 at 21:32

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.