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):
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.
Answer
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.
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.
No comments:
Post a Comment