<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Michael,</p>
<p>you need to add the python\plugins folder to the pythonpath as
well, either in your batch file or PyCharm<br>
</p>
<p><img src="cid:part1.nP2iDPbz.6X8l2lDP@geo.hu-berlin.de" alt=""></p>
<p>Greetings,</p>
<p>Benjamin<br>
</p>
<div class="moz-cite-prefix">Am 28/06/2022 um 15:17 schrieb Egenolf,
Michael via QGIS-Developer:<br>
</div>
<blockquote type="cite"
cite="mid:12c7e993b8fc46e7900e5e0ff563ca0b@bezreg-koeln.nrw.de">
<pre class="moz-quote-pre" wrap="">Dear QGIS-Develeopers,
I was trying to figure out how to get going with the processing modul in Pyqgis.
It seems that I am not able to load the processing tool properly.
1)
I did make a bat file with the right pathes as followed:
@echo off
SET OSGEO4W_ROOT=C:\brk\programme\QGIS 3.16
call %OSGEO4W_ROOT%\bin\o4w_env.bat
call %OSGEO4W_ROOT%\apps\grass\grass78\etc\env.bat
path %path%;%OSGEO4W_ROOT%\apps\qgis-ltr\bin
path %path%;%OSGEO4W_ROOT%\apps\grass\grass78\lib
path %path%;C:\OSGeo4W\apps\qt5\bin
path %path%;C:\OSGeo4W\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
start "Pycharm aware of QGIS" /B "C:\brk\programme\PyCharm-Community_2021.3\bin\pycharm64.exe" %*
2)
After that I am loading Pycharm and I am using the following interpreter:
C:\brk\programme\QGIS 3.16\bin\python-qgis-ltr.bat
3)
This is my python code I want to run:
from qgis import processing
input = r'dein SHP Layer'
outputWithLayer = 'memory ' # kannst den Layer lokal in einem Ordner speichern z.B. C:\test\shpfile.shp
def buffer(input, outputWithLayer):
buffer_result = processing.run("native:buffer", {
'INPUT': input,
'DISTANCE': 10000,
# 'DISSOLVE': True,# Falls du alle Polygonen mergen willst
'OUTPUT': outputWithLayer
})
bufferresult = buffer(input, outputWithLayer)
print(bufferresult)
# result_layer = buffer_result['OUTPUT']
# layer = QgsVectorLayer(result_layer,"test","ogr")
# QgsProject.instance().addMapLayer(layer)
4) Result
Stil if I want to import processing as suggested everywhere there will always fail because the eather the modul is not importet or when I am using the buffer the run() method is not found:
"C:\brk\programme\QGIS 3.16\bin\python-qgis-ltr.bat" C:/Users/Egenolf/AppData/Roaming/JetBrains/PyCharmCE2021.3/scratches/Test_Pyqt.py
Traceback (most recent call last):
File "C:/Users/Egenolf/AppData/Roaming/JetBrains/PyCharmCE2021.3/scratches/Test_Pyqt.py", line 13, in <module>
import processing
ModuleNotFoundError: No module named 'processing'
Even after an intensive research on stackexchange/ GISstackexchange pages there is not clear solucion to this point or the solucion is not adapted to Python 3.
Does anybody has a good loading script or some hints on how to solve this problem?
Best regards
Michael Egenolf
_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Benjamin Jakimow, Doctoral Researcher
Earth Observation Lab | Geography Department | Humboldt-Universität zu Berlin
e-mail: <a class="moz-txt-link-abbreviated" href="mailto:benjamin.jakimow@geo.hu-berlin.de">benjamin.jakimow@geo.hu-berlin.de</a>
phone: +49 (0) 30 2093 6846
mobile: +49 (0) 157 5656 8477
fax: +49 (0) 30 2093 6848
mail: Unter den Linden 6 | 10099 Berlin | Germany
room: 2'211
web: <a class="moz-txt-link-freetext" href="https://hu-berlin.de/eo-lab">https://hu-berlin.de/eo-lab</a></pre>
</body>
</html>