<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic AttributeError: 'module' object has no attribute 'utils' in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/attributeerror-module-object-has-no-attribute/m-p/363226#M28723</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We're getting this error periodically. Out of hundreds of successful requests it'll happen about twice. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT] {"error":{"code":400,"message":"Unable to complete operation.","details":["Error executing tool.: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File \"D:\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\EDDM\\getRouteStats.GPServer\\extracted\\v101\\eddm\\getRouteStats.py\", line 3, in \u003cmodule\u003e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; import sys, os, arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File \"d:\\arcgis\\server\\arcpy\\arcpy\\__init__.py\", line 33, in \u003cmodule\u003e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; import arcpy.utils as utils&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; AttributeError: 'module' object has no attribute 'utils'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Failed to execute (getRouteStats).\nFailed to execute (getRouteStats)."]}}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's thrown on a line written by arcgis: import sys, os, arcpy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jun 2014 12:23:07 GMT</pubDate>
    <dc:creator>KyleDixon</dc:creator>
    <dc:date>2014-06-16T12:23:07Z</dc:date>
    <item>
      <title>AttributeError: 'module' object has no attribute 'utils'</title>
      <link>https://community.esri.com/t5/python-questions/attributeerror-module-object-has-no-attribute/m-p/363226#M28723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We're getting this error periodically. Out of hundreds of successful requests it'll happen about twice. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT] {"error":{"code":400,"message":"Unable to complete operation.","details":["Error executing tool.: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File \"D:\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\EDDM\\getRouteStats.GPServer\\extracted\\v101\\eddm\\getRouteStats.py\", line 3, in \u003cmodule\u003e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; import sys, os, arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; File \"d:\\arcgis\\server\\arcpy\\arcpy\\__init__.py\", line 33, in \u003cmodule\u003e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; import arcpy.utils as utils&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; AttributeError: 'module' object has no attribute 'utils'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Failed to execute (getRouteStats).\nFailed to execute (getRouteStats)."]}}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's thrown on a line written by arcgis: import sys, os, arcpy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2014 12:23:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attributeerror-module-object-has-no-attribute/m-p/363226#M28723</guid>
      <dc:creator>KyleDixon</dc:creator>
      <dc:date>2014-06-16T12:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: 'module' object has no attribute 'utils'</title>
      <link>https://community.esri.com/t5/python-questions/attributeerror-module-object-has-no-attribute/m-p/363227#M28724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2014 20:42:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attributeerror-module-object-has-no-attribute/m-p/363227#M28724</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-06-16T20:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: 'module' object has no attribute 'utils'</title>
      <link>https://community.esri.com/t5/python-questions/attributeerror-module-object-has-no-attribute/m-p/363228#M28725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The error occurs on this line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# 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&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Interestingly, when I launch the new service, there are no esri added imports or variables, only the original code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
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&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:55:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/attributeerror-module-object-has-no-attribute/m-p/363228#M28725</guid>
      <dc:creator>KyleDixon</dc:creator>
      <dc:date>2021-12-11T16:55:59Z</dc:date>
    </item>
  </channel>
</rss>

