3

How to setup Python interpreter in IDE to develop using Processing module? I need this not for running from IDE, but to have tips about classes, methods, arguments etc.

  • IDE: PyCharm 2016.3 (but example in any IDE will be helpful).
  • OS: Ubuntu 16.04 (any Linux example will be OK too).

In my current PyCharm settings project interpreter located at: /usr/bin/python2.7 and imports from module QGIS works fine, but not from processing (red curved underlines):

example of imports

I've discovered, that processing located at /usr/share/qgis/python/plugins/processing but don't know what to do with this info.

And second. If anybody knows how to setup python virtual environment with all modules, that needed for QGIS plug-in developing, please tell. It may be helpful too. Especially if I��ll develop standalone app in future.

3
  • Did you try to set QGIS python interpriter or change rpoject root directory in Pycharm settings?? Commented Mar 16, 2017 at 18:27
  • Yes I've tried. But it didn't help. But I already answered in my question. Commented Mar 17, 2017 at 8:45
  • I just follow your steps. Could you include in your answer what libraries and modules do you import to make it work? For the virtual environment, I use conda (miniconda). Are you still interested in it? It is for QGIS plugin development?
    – Pin_Eipol
    Commented Feb 13, 2020 at 15:00

1 Answer 1

8

I’ve found the solution of my main question with help of this answer.

If you need to add some external library, first of all check where it is placed (if it is possible of course). I opened Python console in QGIS and inserted:

from processing.core import AlgorithmProvider
AlgorithmProvider.__file__

output:

'/usr/share/qgis/python/plugins/processing/core/AlgorithmProvider.py'

Since QGIS 3.0 AlgorithmProvider is not presented. That's why you can import any other module. For example:

from processing.core import Processing
Processing.__file__

output:

'/usr/share/qgis/python/plugins/processing/core/Processing.py'

So, like I already wrote, in my computer processing module located at /usr/share/qgis/python/plugins

In PyCharm: File → Settings → Project:… Project Interpreter

Click on button to show list of available interpreters. At the bottom click “Show All”. In new dialog window click last button like showed on image.

screenshot of PyCharm dialog

Then click “+” button and add new path to your external library. I added /usr/share/qgis/python/plugins

Thats all. Now new library is available in PyCharm.

P.S. If you know something about setting virtual environment, I am still interested in it.

1
  • That work for me, i can import processing. But now i got the error "_core.QgsProcessingException: Error: Algorithm qgis:Buffer not found", i will keep look around. Thanks! Commented Oct 8, 2021 at 18:05

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