<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Verdana",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Hello,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>I‘ m trying to access commands from the processing toolbox from outside a QGIS Session via Python. I found an example made by Ujaval Gandhi (spatialthoughts.com) which contains the following:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'># Add the path to Processing framework<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>sys.path.append('c:\\Users\\myUsername\\.qgis2\\python\\plugins')<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'># Import and initialize Processing framework<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>from processing.core.Processing import Processing<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Processing.initialize()<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>import processing<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>That did not work for me (in QGIS 2.12 and 2.14), I got an error message "Import error: no module named processing.core.Processing".<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>I checked the path and found that there is no file „Processing.py“ in that folder under .qgis2. So I wonder how it should be found there?<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Now, I started to look for the file myself using the command window MS-DOS: dir /s processing.py, and the file was found in:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Verzeichnis von C:\Program Files\QGIS Essen\apps\qgis\python\processing\core<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Processing.py 15.578 Bytes ...<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>I tried that path for sys.path.append() in the above code and got the same error as before.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Then, I started QGIS (by the way: I started it just as a check. I'd like to create a script that works from outside QGIS).<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>In the QGIS Python console, it' no problem to import processing. That means that it is present on the computer. So I checked the path that is used here: <o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>import sys<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>print sys.path<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>I got a very long confusing list, but the only entry containing the string "processing" is:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>'C:/PROGRA~1/QGISES~1/apps/qgis/./python/plugins\\processing'<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>So I thougt that this must be the path to import processing.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>But trying exactly that in the above code, I got the same error as above.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Now, my questions are:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>what did I do wrong? where is Processing.py to be found?<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Why did my search produce wrong results? Am I wrong in assuming that I have to provide the path to „Pythonfile.py“ if I want „import Pythonfile“ to work??<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Verdana",sans-serif'>Thanks and regards, Uwe<o:p></o:p></span></p></div></body></html>