Select to view content in your preferred language

AttributeError: 'module' object has no attribute 'utils'

3780
2
06-16-2014 05:23 AM
KyleDixon
Deactivated User
We're getting this error periodically. Out of hundreds of successful requests it'll happen about twice.

[INDENT] {"error":{"code":400,"message":"Unable to complete operation.","details":["Error executing tool.:
Traceback (most recent call last):
File \"D:\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\EDDM\\getRouteStats.GPServer\\extracted\\v101\\eddm\\getRouteStats.py\", line 3, in \u003cmodule\u003e
import sys, os, arcpy
File \"d:\\arcgis\\server\\arcpy\\arcpy\\__init__.py\", line 33, in \u003cmodule\u003e
import arcpy.utils as utils
AttributeError: 'module' object has no attribute 'utils'
Failed to execute (getRouteStats).\nFailed to execute (getRouteStats)."]}}
[/INDENT]

It's thrown on a line written by arcgis: import sys, os, arcpy
Tags (2)
0 Kudos
2 Replies
Zeke
by
Honored Contributor
Might help to post the problem code section. As a guess, are you checking for None values before executing the code? Another option might be to not alias arcpy.utils, and call it as arcpy.utils. No idea why that would be an error, but worth a shot.
0 Kudos
KyleDixon
Deactivated User
The problem is in the ArcGIS rewritten code, I am checking for none variables, but the rewritten code removes it. I'm not referencing the utils package in my code.
The error occurs on this line:


# Esri start of added imports
import sys, os, arcpy
# Esri end of added imports

# Esri start of added variables
g_ESRI_variable_1 = u'"ZIP_CRID" in ('
g_ESRI_variable_2 = u'USPS_CRID_T'
g_ESRI_variable_3 = u'\\\\localhost\\arc10data\\EDDM\\logs\\getRouteStats.log'
# Esri end of added variables

import arcpy, re


I removed the arcpy import and loaded only the modules I needed, our ESRI technical adviser said it loads all modules by default, that's why it takes so long to start a service.
Interestingly, when I launch the new service, there are no esri added imports or variables, only the original code.

import re
from arcpy import GetParameterAsText as GetParameterAsText
from arcpy import TableSelect_analysis as TableSelect_analysis
from arcpy import SetParameterAsText as SetParameterAsText
from arcpy import AddError as AddError
0 Kudos