5

I am writing a plugin for QGIS 2.0, and I want to use the processing framework to call some functions.

When I open the pyhton console inside QGIS, I am able to call it like this:

    >> import processing

And then, for instance:

    >>> processing.alglist()

However, if I try to import it in my Python Plugin, it fails to find the processing include:

    from qgis.core import *
    from qgis.gui import *
    import processing

I googled the problem and found this directives:

    from processing.core.Processing import Processing
    from processing.core.ProcessingConfig import Setting, ProcessingConfig

But unfortunately it also does not work for me :-/

Does anybody know how to include the qgis processing framework in a plugin, and how to call the algorithm (lets say for instance "processing.runalg(...)

I really appreciate your answers, as I found many explanations on how-to do it in the Python console, but not outside QGIS :-/

Thanks again for your time and have a nice day, Joana

  • 1
    Ok, I will answer my own question. Using exactlythe same imports as in the python console works; is just a problem of pydev, that doesn't recognize the libraries (I probably need to add a reference in the project somewhere) – doublebyte Oct 11 '13 at 13:35
  • blog.vitu.ch/01082013-1452/… Section Make eclipse understand the API add a path to your core plugins python folder there. – Matthias Kuhn Oct 11 '13 at 13:51
  • @doublebyte You can answer your own question in the answers section. This way, you can collect upvotes and eventually, even accept your own answer. – underdark Oct 13 '13 at 17:59
  • Thanks Underdark :-) I tried to do it almost straight away as soon as I realized, but since I do not have a high reputation yet, it said I had to wait 2 hours. I did it now!! – doublebyte Oct 14 '13 at 7:11
  • @MatthiasKuhn: Thanks Matthias; I had already added the python plugin path and the python package path to the libraries and my environment picks them up correctly; I now forced the builtins: qgis and pyQT4, but my eclipse environment did not change: it debugs correctly without errors, but this line: "import processing", gets the "processing" word underlined in red, which means it does not understand the include; for the same reason, I don't get the auto complete for processing functions :-/ – doublebyte Oct 14 '13 at 7:30
1

Ok, I will answer my own question. Using *exactly*the same imports as in the python console works; is just a problem of pydev, that doesn't recognize the libraries (I probably need to add a reference in the project somewhere)

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.