# ZeroDivisionError

I was conducting Mean Coodinates process functions with weighted fields when I began faces ZeroDivision errors in some processes.

The Shapefile Data has been joined together with imported Spreadsheet data.

I have to run this simulation multiple times and about 70% of the times it has worked without errors while it is giving the following error with the combination of particular shapefiles with certain weighted means.

the error is:

Uncaught error while executing algorithm

Traceback (most recent call last):

Traceback (most recent call last):

File "C:/PROGRA~1/QGISCH~1/apps/qgis/./python/plugins\processing\core\GeoAlgorithm.py", line 217, in execute self.processAlgorithm(progress)

File "C:/PROGRA~1/QGISCH~1/apps/qgis/./python/plugins\processing\algs\qgis\ftools\MeanCoords.py", line 119, in processAlgorithm

cx = values[0] / values[2]

ZeroDivisionError: float division by zero

What is the issue and how can it be solved?

• The issues seems to be that you can't divide by 0 eg. 3.4/0. This link reference "exception ZeroDivisionError" indicates "Raised when the second argument of a division or modulo operation is zero". Somewhere in your values for "values[2]" you have zeros present. – TsvGis Jul 25 '15 at 23:44
• Try to add a print (values[2]) ; assert values[2] != 0 at line 118. As some point, this assertion will probably fail. – boardrider Jul 26 '15 at 12:20
• Maybe there is no data in tour variable, check with a print or something else – jlSta Feb 24 '17 at 8:10
• Welcome to gis.stackexchange! Please edit the title of your question to include enough information for future visitors to be able to find this thread when looking for the same problem. – underdark Apr 19 '18 at 20:30

if values[2] != 0: