<?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: AGOL Notebook crashing with &amp;quot;import arcgisscripting&amp;quot; in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1175783#M64594</link>
    <description>&lt;P&gt;Use &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;arcpy.ExecuteError&lt;/FONT&gt; instead:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

try:
    arcpy.do_something()
except arcpy.ExecuteError as e:
    handle_error(e)&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 19 May 2022 22:55:02 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2022-05-19T22:55:02Z</dc:date>
    <item>
      <title>AGOL Notebook crashing with "import arcgisscripting"</title>
      <link>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1175707#M64593</link>
      <description>&lt;P&gt;I am using an "Advanced" kernel Notebook in ArcGIS Online for Organizations. When I do an&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcpy.management.Delete(&amp;lt;path&amp;gt;)&lt;/FONT&gt; on a file geodatabase, it is often locked, so Delete returns an exception of type &lt;FONT face="courier new,courier" color="#993300"&gt;arcgisscripting.ExecuteError&lt;/FONT&gt;, so I have a try/except block to catch this exception type and log a warning. This works great on my PC and a Windows server running ArcPy.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;U&gt;Running in an AGOL Notebook (AGOL for Organizations)&lt;/U&gt;&lt;/EM&gt;, however, just doing the import for this crashes the kernel. I get an error pop-up titled "&lt;FONT face="courier new,courier"&gt;Kernel Restarting&lt;/FONT&gt;" with the message "&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;The kernel appears to have died. It will restart automatically.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;" The browser window never restarts the kernel and it just sits there with a "Dead kernel" message and an icon with a spy-vs-spy bomb with a lit fuse.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is not just a Python exception, but rather is basically my whole OS crashing. Therefore, putting the import in a try/except block does not prevent this.&amp;nbsp;Before I ramble on any more, &lt;EM&gt;&lt;U&gt;has anyone seen this and gotten it working&lt;/U&gt;&lt;/EM&gt;?&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;Code samples and screenshots below. Check to see if the package is installed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import importlib
spec = importlib.util.find_spec("arcgisscripting")
print(spec)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The print statement produces this, so I believe the package is present:&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2" color="#339966"&gt;ModuleSpec(name='arcgisscripting', loader=&amp;lt;_frozen_importlib_external.SourceFileLoader object at 0x7fd50d03b490&amp;gt;, origin='/opt/conda/lib/python3.7/site-packages/arcgisscripting/__init__.py', submodule_search_locations=['/opt/conda/lib/python3.7/site-packages/arcgisscripting'])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I normally just import it, but even putting it in a try/except block fails. It also fails if I try to just import the specific exception class.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:
    import arcgisscripting  # THIS LINE FAILS
except Exception as ex: 
    print(f"Exception: {ex}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When it runs the import (line 2), I get this pop-up:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dcafdg_0-1652987944723.png" style="width: 570px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41761i9FB073AD1E6DBBE7/image-dimensions/570x141?v=v2" width="570" height="141" role="button" title="dcafdg_0-1652987944723.png" alt="dcafdg_0-1652987944723.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Despite what the error message says, I have never seen it restart itself in my browser tab, which just sits there with these ominous looking icons:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dcafdg_1-1652988057219.png" style="width: 360px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41762i857917351B7C4811/image-dimensions/360x108?v=v2" width="360" height="108" role="button" title="dcafdg_1-1652988057219.png" alt="dcafdg_1-1652988057219.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any ideas? thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 19:35:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1175707#M64593</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-05-19T19:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: AGOL Notebook crashing with "import arcgisscripting"</title>
      <link>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1175783#M64594</link>
      <description>&lt;P&gt;Use &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;arcpy.ExecuteError&lt;/FONT&gt; instead:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

try:
    arcpy.do_something()
except arcpy.ExecuteError as e:
    handle_error(e)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 May 2022 22:55:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1175783#M64594</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-05-19T22:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: AGOL Notebook crashing with "import arcgisscripting"</title>
      <link>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1177623#M64633</link>
      <description>&lt;P&gt;Thanks, Luke. When the exception is raised, it is type&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgisscripting.ExecuteError&lt;/FONT&gt;. I can use that type to catch the exception in my ArcGIS Pro conda environment, but it crashes the whole kernel on AGOL Notebooks. It looks like&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgisscripting.ExecuteError&lt;/FONT&gt; inherits from &lt;FONT face="courier new,courier" color="#993300"&gt;arcpy.ExecuteError&lt;/FONT&gt;, or something like that.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; try:
&amp;gt;&amp;gt;&amp;gt;     '''Some code that fails'''
&amp;gt;&amp;gt;&amp;gt; except Exception as ex:
&amp;gt;&amp;gt;&amp;gt;     ex
ExecuteError('ERROR 000464: Cannot get exclusive schema lock.  Either being edited or in use by another application or service.\nFailed to execute (Delete).\n')
&amp;gt;&amp;gt;&amp;gt;     type(ex)
&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;
&amp;gt;&amp;gt;&amp;gt;     import arcgisscripting
&amp;gt;&amp;gt;&amp;gt;     type(ex) is arcgisscripting.ExecuteError
True
&amp;gt;&amp;gt;&amp;gt;     import arcpy
&amp;gt;&amp;gt;&amp;gt;     type(ex) is arcpy.ExecuteError
True&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be nice if the exception were of the type that Esri actually intends for us to use. I usually catch the most specific type of exception I need to, but maybe just using the default Python&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;Exception&lt;/FONT&gt; is easier if I don't need anything specific from this exception type. In this case, I'm just doing &lt;FONT face="courier new,courier" color="#993300"&gt;arcpy.management.Delete&lt;/FONT&gt; and it's failing because there are locked resources.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 17:18:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1177623#M64633</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-05-26T17:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: AGOL Notebook crashing with "import arcgisscripting"</title>
      <link>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1177856#M64648</link>
      <description>&lt;P&gt;arcpy.ExecuteError &lt;EM&gt;is&lt;/EM&gt;&amp;nbsp;arcgisscripting.ExecuteError&lt;/P&gt;&lt;LI-CODE lang="python"&gt;print(arcpy.ExecuteError)
&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Might be something happening when arcgisscripting gets imported in arcpy that causes a crash when you import it again in your notebook context. Worth reporting as a bug perhaps.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 06:18:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1177856#M64648</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-05-27T06:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: AGOL Notebook crashing with "import arcgisscripting"</title>
      <link>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1178002#M64649</link>
      <description>&lt;P&gt;I'm familiar enough with Esri's coding practices to know how convoluted things get with inheritance (or whatever this case is), but I really don't get why things from two entirely different packages are so intertwined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is part of a general tool I maintain at my organization. I don't necessarily know what my users are trying to do with it, so I wanted to provide as much information as I can about the error. That said, I don't have any specific use case for needing to know why it failed. Since the last thing I want is for my error handling to be a source of errors, I'm just going to catch it as the general Python Exception type going forward.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 15:41:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-notebook-crashing-with-quot-import/m-p/1178002#M64649</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-05-27T15:41:38Z</dc:date>
    </item>
  </channel>
</rss>

