How to save an ArcGIs Pro Notebook as a p Pyhton script

373
2
05-08-2024 11:31 AM
Labels (1)
JoseSanchez
Frequent Contributor

Hello everyone,

Is there a way to save all the code created in a Notebook as a Python file?

Thanks

 

 

 

0 Kudos
2 Replies
Brian_Wilson
Honored Contributor

Notebook files get created when you save a project. They usually have a name like "New Notebook" with a number after them.

From a command shell, you should be able to run conda to activate an environment then use the jupyter command, like this (On my installation, conda is in "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\")

 

conda activate arcgispro-py3
jupyter nbconvert "New Notebook.ipynb" --to script

 

 This wrote a file called "New Notebook.ipynb" with the contents of each cell from the notebook. In my simple case, it's this

 

print("Hello")

 

 

 

0 Kudos
mody_buchbinder
Frequent Contributor

Hi

When you select the notebook tab you have the option to export to Python script.

 

Have fun

0 Kudos