2

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.

  • Did you try to set QGIS python interpriter or change rpoject root directory in Pycharm settings?? – Dmitriy Litvinov Mar 16 '17 at 18:27
  • Yes I've tried. But it didn't help. But I already answered in my question. – Andrey Lekarev Mar 17 '17 at 8:45
7

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.

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.