<?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 Re: Standard python module ImportError in Geoprocessing Service in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341566#M13105</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;strange then...does it do this with other python modules or just json?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Jan 2015 02:15:36 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2015-01-13T02:15:36Z</dc:date>
    <item>
      <title>Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341563#M13102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have recently created a geoprocessing service on ArcGIS server (10.3). When attempting to run this service, it fails almost immediately. Upon checking in the log files, I am getting an ImportError, specifically:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #505051; font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #e5edf4;"&gt;Traceback (most recent call last): File "B:\arcgisserver\directories\arcgissystem\arcgisinput\ConfirmationSampling.GPServer\extracted\v101\webapp\confirmation_sampling.py", line 63, in &lt;/SPAN&gt;import json ImportError: No module named json Failed to execute (ConfirmationSampling). Failed to execute (ConfirmationSampling).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, json is a standard python module and should be included in python without having to install a module, to my knowledge. I have tried to import it in the interpreters installed on the system and they have no problem doing so. Is there some python installation that ArcGIS server uses that I have to explicitly install this module for? If so can someone please tell me where it is, or link me to relevant documentation on this topic? I have been unsuccessful finding anything so far. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jan 2015 23:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341563#M13102</guid>
      <dc:creator>ClintDow</dc:creator>
      <dc:date>2015-01-12T23:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341564#M13103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you still have to import it within your script, just like numpy, or string or os or sys&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; import json
&amp;gt;&amp;gt;&amp;gt; dir(json)
['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__', '__doc__', '__file__', 
'__name__', '__package__', '__path__', '__version__', '_default_decoder', '_default_encoder', 'decoder',
 'dump', 'dumps', 'encoder', 'load', 'loads', 'scanner']&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:07:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341564#M13103</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T16:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341565#M13104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing that. In fact the traceback I posted contains 'import json' as the offending line of code, and ImportError itself is only thrown when an import or from ... import statement fails. If I didn't import the module and tried to use it, then it would raise a NameError.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script runs successfully in ArcMap, and satisfies multiple unit and acceptance tests run via the command line, so I am sure the code itself is not problematic. Its just this one import statement while run as a geoprocessing service that is the issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 00:35:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341565#M13104</guid>
      <dc:creator>ClintDow</dc:creator>
      <dc:date>2015-01-13T00:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341566#M13105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;strange then...does it do this with other python modules or just json?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 02:15:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341566#M13105</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-01-13T02:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341567#M13106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Other modules import successfully, such as math, datetime and so forth. It seems just to be json that is problematic. I have found that when checking sys.executable from within a geoprocessing service, it returns the path to ArcSOC.exe, so they have baked an interpreter via COM into that executable I believe. As such I'm not sure where I would even install a module via pip, or if its possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 18:18:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341567#M13106</guid>
      <dc:creator>ClintDow</dc:creator>
      <dc:date>2015-01-13T18:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341568#M13107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is not good.&amp;nbsp; Keep us posted&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jan 2015 18:35:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341568#M13107</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-01-13T18:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341569#M13108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, I managed to track down a little documentation on this. &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//01540000054p000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//01540000054p000000"&gt;ArcGIS Help 10.1&lt;/A&gt; "Importing other python modules"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately the methods suggested in the documentation didn't work. Long story short I had zero success with the recommended methods of using sys.path.append, or the consolidation method. I eventually had to copy my own modules into the site-packages folder for the ArcGISx6410.3 folder within Python27. Hopefully if anyone else has this issue this might help them. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Jan 2015 19:16:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341569#M13108</guid>
      <dc:creator>ClintDow</dc:creator>
      <dc:date>2015-01-15T19:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Standard python module ImportError in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341570#M13109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've just run into this problem, so it's good to know (not really, but you know what I mean) that someone else has come across it. Using sys.path.append did work for me, but it meant that all dependencies (including lots of python builtins) and files in the script folder were copied to the package folder on the server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was even the case when putting the imported module in a subfolder on its own and appending the path with&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'utils'))&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Looks like this needs to be raised as a bug, because the &lt;A href="http://server.arcgis.com/en/server/latest/publish-services/windows/authoring-geoprocessing-tasks-with-python-scripts.htm#ESRI_SECTION1_87AFC11351574AD1A085A2528D946D3A"&gt;10.3 help&lt;/A&gt; still says that the script should be copied if it is in the same folder.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 13:36:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/standard-python-module-importerror-in/m-p/341570#M13109</guid>
      <dc:creator>JonMorris2</dc:creator>
      <dc:date>2015-11-04T13:36:55Z</dc:date>
    </item>
  </channel>
</rss>

