Hello all,
Could you please help me find out why and how to fix a Geoprocessing model (v10)? The current model calculates census data and needs to have an if-then-else using the Calculate Value tool. The code below is working wonderfully on desktop, but crashes in a service with the following error:
Error 000539: Error running expression: x(r"c:\arcgisserver\arcgisjobs\Population_tools\model3_gpserver\jb18558850e7e47799a\scratch\scratch.gdb\Census_join") <type 'exceptions.ImportError'>: No module named collections
Failed to execute
Python code within Calculate Value in Geoprocessing Service:
# First Calculate Value should count the number of rows in the feature class and continue with
# the calculations if it is = 1 row.
Expression:
x(r"%Census_join%")
Code Block:
def x(InputFeatureClass):
import arcpy
result = arcpy.GetCount_management(InputFeatureClass)
if int(result.getOutput(0)) == 1:
return "true"
else:
return "false"
# Second Calculate Value should count the number of rows in the feature class and continue with
# the calculations if there is > 1 row.
Expression:
x(r"%Census_join%")
Code Block:
def x(InputFeatureClass):
import arcpy
result = arcpy.GetCount_management(InputFeatureClass)
if int(result.getOutput(0)) == 1:
return "false"
else:
return "true"
Data type: Boolean
Any help to make this work as a service...would be hugely helpful!
Thank you.