I am using QGIS 3.2 on Windows7. I had successfully set all enviroment variables in OSGeo4W shell. I have run small scripts without any issue. I have to run

processing.run('native:centroids', {'INPUT':'C:/Test/demand/valid.shp','ALL_PARTS':True,'OUTPUT':'C:/Test/demand/centroid.shp'})

The above line works perfectly in console within QGIS. But when I try to run in standalone scripts it is giving following error:

enter image description here

Although, in my script I have added below lines and I was able to execute processing.run('qgis:voronoipolygons', parameters)

import processing
from processing.core.Processing import Processing
from processing.tools import *

I don't understand where I am doing wrong.

  • 2
    Please remember to always include the entire error message as text, in the body of the question. This will assure that the message is legible on all display devices, and will permit indexing for free text search, so that others can find your answer.
    – Vince
    Commented Sep 29, 2018 at 14:36
  • I will keep this in mind henceforth
    – ps1
    Commented Sep 29, 2018 at 15:44

1 Answer 1


I got my mistake. The below lines should be added before calling native algorithms. It works fine now.

 from qgis.analysis import QgsNativeAlgorithms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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