I am trying to calculate the centroids of polygons using PyQGIS.
When I calculate the centroids with the interface (Vector --> Geometry Tools --> Polygon Centroids) everything works out.
However, I fail to reproduce the same using the python console in QGIS (version 2.18.16).
Following the history output after conducting the operation manually as well as the QGIS documentation, I use this line of code:
processing.runalg("qgis:polygoncentroids", shapefile, "memory:")
This produces the error:
NameError: name 'processing' is not defined
What am I doing wrong here?