3

I want to create a standalone pyQGIS script in python editor but I have importing error on Processing

import sys
from qgis.core import *
sys.path.append('/usr/share/qgis/python/plugins')
import Processing

I turn for similar question and all suggestion import path for Processing plugins and I add this path and I have error again. How to fix that on Ubuntu 16.04

whyzar
  • 12,053
  • 23
  • 38
  • 72
Chris Papas
  • 717
  • 2
  • 9
  • 20

2 Answers2

2

This Question contains a variety of answers that assisted me when I was building a standalone PyQGIS script and repeatedly had the error no module named qgis and no module named processing.

The answer I used is the one discussing the .bat file that triggers the standalone and connects to the processing toolbox.

1

The module is called processing in small letters

import processing

or

from processing import Processing

Also have a look at this complete example and excellent answer https://gis.stackexchange.com/a/131809/9839

Matthias Kuhn
  • 27,780
  • 3
  • 88
  • 129
  • yes but if i want to import processing algorithm show me error Error: Algorithm not found for ex algorith outputs_SAGASLOPEASPECTCURVATURE_1=processing.runalg('saga:slopeaspectcurvature', dem,6,1,1,slope,aspect,None,None,None,None,None,None,None,None,None,None – Chris Papas Dec 21 '16 at 18:29
  • Have you initialized processing? http://gis.stackexchange.com/questions/131764/run-processing-toolbox-outside-qgis-in-standalone-app – Matthias Kuhn Dec 21 '16 at 18:30
  • yes i have i can see in QGIS and in QGIS folder,and from processing import Processing not work – Chris Papas Dec 21 '16 at 18:32
  • Can you confirm: the code snippet from this answer does not work for you: http://gis.stackexchange.com/a/131809/9839 – Matthias Kuhn Dec 21 '16 at 18:34
  • i dont understand – Chris Papas Dec 21 '16 at 18:40
  • Open the link in my last comment, copy and paste the code there and check if this also produces an error. – Matthias Kuhn Dec 21 '16 at 18:41
  • i have do that, now dont show anythink not error not print,why ? – Chris Papas Dec 21 '16 at 18:49
  • not work again if i add line SAGASLOPEASPECTCURVATURE_1=processing.runalg('saga:s‌​lopeaspectcurvature'‌​, dem,6,1,1,slope,aspect,None,None,None,None,None,None,None,No‌​ne,None,None) and define inputs and outputs not work again dont show me anythink – Chris Papas Dec 21 '16 at 18:56
  • I would recommend to open a new question as per the site policy of "one question per post" – Matthias Kuhn Dec 21 '16 at 19:01