jeudi 29 janvier 2015

Run processing toolbox outside QGIS in standalone app


I am developing a standalone app in Python, using QGIS libraries including processing algorithms. I am developing in Linux environment and I put the libraries in a folder. Also I put the processing folder from QGIS in that same folder. I run the app but when I import the processing folder, it gives me nothing (not even error messages).


I import like that:



import processing.core.Processing


Can you help me?


CODE:



import sys
import qgis.core
import PyQt4.QtCore
import PyQt4.QtGui
app = qgis.core.QgsApplication([],True)
qgis.core.QgsApplication.setPrefixPath("/usr", True)
qgis.core.QgsApplication.initQgis()


(from here the program doesn't work)



from processing.core.Processing import Processing
inputLayer = 'c:....'
inputMask = 'c:....'

extent = ....
cellsize = ....
outPath = 'c:.....'

Processing.Initialize()
Processing.runalgorith(.....)


UPDATE:


Ok, I download the folder with the processing version 2.2.0-2 and I copied to my script folder. I run and it gives me this error:



Traceback (most recent call last):
File "teste.py", line 12, in <module>
from processing.core.Processing import Processing
File "/home/p/Programas/processing/__init__.py", line 28, in <module>
from processing.tools.dataobjects import *
File "/home/p/Programas/processing/tools/dataobjects.py", line 33, in <module>
from processing.core.ProcessingConfig import ProcessingConfig
File "/home/p/Programas/processing/core/ProcessingConfig.py", line 30, in <module>
from processing.tools.system import *
File "/home/p/Programas/processing/core/processing.py", line 33, in <module>
from processing import interface
ImportError: cannot import name interface


I still have no answer.


UPDATE:


I got it!! What is missing in my case was to define the PYTHONPATH to the folder with the processing. Now I have the correct running of the code.


Thanks for the help.





Aucun commentaire:

Enregistrer un commentaire