2

I would like to join attributes by location using standalone PyQGIS but im getting error. I have QGIS 3.16 installed on my machine.

from qgis.core import *

QgsApplication.setPrefixPath("C:/Program Files/QGIS 3.16/apps/qgis", True)
qgs = QgsApplication([], True)
QgsApplication.initQgis()

import processing
from processing.core.Processing import Processing
Processing.initialize()

processing.run("qgis:joinattributesbylocation", {
            'INPUT':'C:/Users/ja/Inne/Desktop/bdot10k_bubd_a/bdot10k_bubd_a.gpkg', 
            'JOIN':'C:/Users/ja/Inne/Desktop/POLSKA/PRG_PunktyAdresowe_POLSKA.shp',
            'PREDICATE':[1,5],
            'JOIN_FIELDS':['PNA','SIMC_id','SIMC_nazwa','ULIC_nazwa','Numer'],
            'METHOD':1,
            'DISCARD_NONMATCHING':True,
            'PREFIX':'',
            'OUTPUT':'C:/Users/ja/Inne/Desktop/projekt2.gpkg'})

And im getting the error:

Traceback (most recent call last): File "", line 1, in File "C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python/plugins\processing\tools\general.py", line 108, in run return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context) File "C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python/plugins\processing\core\Processing.py", line 141, in runAlgorithm raise QgsProcessingException(msg) _core.QgsProcessingException: Error: Algorithm qgis:joinattributesbylocation not found

What is the problem?

  • What if you try running Processing.updateAlgsList() after Processing.initialize()? Additionally make sure that %QGIS_PATH%\apps\qgis\python\plugins\processing is added to the PYTHON_PATH environment variable. – Taras Nov 3 at 7:27
  • I solved that problem, thank you. I have another problem: gis.stackexchange.com/questions/378188/… – datasciencebegginer Nov 3 at 7:29
0

Solution:

I transfered folder "platforms" (C:\Program Files\QGIS 3.16\apps\qt5\plugins\platforms) to:

C:\Program Files\QGIS 3.16\bin and C:\Program Files\QGIS 3.16\apps\Python37

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.