I am using an "Advanced" kernel Notebook in ArcGIS Online for Organizations. When I do an arcpy.management.Delete(<path>) on a file geodatabase, it is often locked, so Delete returns an exception of type arcgisscripting.ExecuteError, 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.
Running in an AGOL Notebook (AGOL for Organizations), however, just doing the import for this crashes the kernel. I get an error pop-up titled "Kernel Restarting" with the message "The kernel appears to have died. It will restart automatically." 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.
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. Before I ramble on any more, has anyone seen this and gotten it working?
Code samples and screenshots below. Check to see if the package is installed.
import importlib
spec = importlib.util.find_spec("arcgisscripting")
print(spec)
The print statement produces this, so I believe the package is present:
ModuleSpec(name='arcgisscripting', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fd50d03b490>, origin='/opt/conda/lib/python3.7/site-packages/arcgisscripting/__init__.py', submodule_search_locations=['/opt/conda/lib/python3.7/site-packages/arcgisscripting'])
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.
try:
import arcgisscripting # THIS LINE FAILS
except Exception as ex:
print(f"Exception: {ex}")
When it runs the import (line 2), I get this pop-up:
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:
Any ideas? thanks!