Select to view content in your preferred language

Unable to upload .py files to new notebook (ArcGIS Pro)

174
3
3 weeks ago
May
by
New Contributor

I am trying to upload a .py file that was given to me by an exiting employee to a new notebook in ArcGIS Pro; however, when I try to "Add Notebook", the .py files aren't available to be selected. It's looking for the notebook file type only and there's no other option for file type in the window. I tried dragging and dropping, using the catalogue... all no luck.

How do I get that .py file into a new notebook??? I'm pulling my hair out trying to figure this out.

0 Kudos
3 Replies
EdMorris
Esri Contributor

Hi

You can load a .py file into a notebook (.ipynb) using a so called IPython magic command:

%load

so, assuming your .py file is in the same directory as your notebook you would type in the code cell:

%load <myPythonFile>.py

and the contents of the .py file is then loaded into the code cell.

I hope this helps!

many thanks ed

BobBooth1
Esri Contributor

You can also open the .PY file in IDLE or a plain text editor, copy the code, and paste it into a notebook cell (or cells).

0 Kudos
EdMorris
Esri Contributor

Hello May

I'm just following up on the suggestions myself and @BobBooth1 offered. Did any of the answers (or both) solve your problem? If so would you mark the answer(s) as a "Solution" as this will help other Community users who will have the same problem in the future to find a suitable answer. Many thanks ed

0 Kudos