I'm new to using notebooks and have started using functions to avoid copying the same code all over the place. I put all these functions in a notebook called MyFunctons and then used the %run "magic" command to import them into any other notebook where I needed to use them. This worked GREAT! ..... Until it didn't
Somewhere along the line it broke and now I get this error:
%run MyFunctions.ipynb ###Import functions from MyFunctions notebook
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
In [2]:
Line 1: %run MyFunctions.ipynb ###Import functions from MyFunctions notebook
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\IPython\core\interactiveshell.py, in run_line_magic:
Line 2418: result = fn(*args, **kwargs)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\decorator.py, in fun:
Line 232: return caller(func, *(extras + args), **kw)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\IPython\core\magic.py, in <lambda>:
Line 187: call = lambda f, *a, **k: f(*a, **k)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\IPython\core\magics\execution.py, in run:
Line 725: raise Exception(msg)
Exception: File `'MyFunctions.ipynb.py'` not found.
---------------------------------------------------------------------------
Note that it started appending ".py" to the notebook file.
I was able to "fix" it by creating a new project, creating new notebooks and copying the code from the broken project/notebook. I don't know if the project got corrupted, or the notebook got corrupted. Searching on the internet it appears that this is a problem others have had elsewhere (not within ArcGIS Pro) but not when it works and then stopped working. It was suggested that a module called import_ipynb is more reliable but it is not among the modules that Pro comes with and I can't use pip to install it.
Does anybody know how this got corrupted and if there is a way to fix it short of rebuilding the whole project?