I am trying to publish an ArcGIS geoprocessing service in 10.2 I have a script setup that will run multiple times through Pycharm, but when I run it in ArcGIS it will run once and return this error:

Traceback (most recent call last): File "C:\Users\Desktop\git\GeoprocessingService.py", line 477, in main() File "C:\Users\Desktop\git\GeoprocessingService.py", line 372, in main cur) File "C:\Users\Desktop/git\GeoprocessingService.py", line 136, in value_query results = cur.fetchall() File "C:\Python27\ArcGIS10.2\lib\site-packages\psycopg2\extras.py", line 81, in fetchall res = super(DictCursorBase, self).fetchall() File "C:\Python27\ArcGIS10.2\Lib\decimal.py", line 543, in new m = _parser(value.strip()) TypeError: 'NoneType' object is not callable

Failed to execute (Script).

The script itself is 800 lines, but here is the query I have been running that errors out:

def value_query(id_field, id, value_fields, start_date, end_date, date_field, table, cur):
    query2 = "SELECT "
    for field in value_fields:
        query2 += "NULLIF({0}, '-999')::NUMERIC(6,2),".format(field)
    query2 += "{0} " \
            "FROM {1} " \
            "WHERE {2} = '{3}' AND {0} BETWEEN '{4}' AND '{5}' " \
            "ORDER BY {0} ASC;".format(date_field, table, id_field, id, start_date, end_date)
    #print "This is Query:"
    #print query

    results = cur.fetchall()

    #print "These are value query results:\n\n {0}".format(results)
    return results

Like I said it runs once in ArcGIS then errors out. However, if I close Arc completely and run the exact same script again, it runs once then stops. I feel like there may be some sort of caching or something that Arc does, but am completely stumped.

1 Answer 1


I had a similar problem and as a work around I changed the decimal values to text values in my postgres database. For whatever reason, there was no issue retrieving text query results. I cast them back to floats later in the python script.


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.