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
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to