ArcGIS Pro 2 Jupyter Notebook Setup Basics

4432
5
07-09-2017 12:38 AM
Labels (1)
MVP Esteemed Contributor
3 5 4,432

In the last blog post... ArcGIS Pro 2... Creating Desktop Shortcuts .. I showed how to create desktop shortcuts to some of the more commonly used applications within esri's distribution of python.  In this post, the Jupyter Notebook will be addressed.

Before you start on this venture, make sure that you have read up on notebooks and see if they are for you and your workflow and not something that '... everyone is doing it, and so should I.... '.  They do have their place, but they require maintenance.

The first order of business.... 

  • Create a folder location to store your notebooks... it is just way easier to keep them in one location and distribute them from there.  I chose to put them in my local machine's GitHub folder, in a separate folder within. ... C:\GitDan\JupyterNoteBooks ... pretty clever ehhh?
  • Right-click on the file ---- "C:/ArcPro/bin/Python/envs/arcgispro-py3/Scripts/jupyter-notebook-script.py" ---- and select create shortcut  which will simply create a shortcut to that file.
    • Go to the Shortcut tab and edit it the Target line and put ...
    • ---- C:\ArcPro\bin\Python\envs\arcgispro-py3\pythonw.exe ---- in front what is there... this will yield the whole path to python in the Pro distribution, plus the script to run (yes, the paths are that long and cryptic).
    • C:\ArcPro\bin\Python\envs\arcgispro-py3\pythonw.exe "C:/ArcPro/bin/Python/envs/arcgispro-py3/Scripts/jupyter-notebook-script.py"
  • In the Start in: line, put the path to the folder that you are going to house your notebooks.  In my example, this was the folder ---- C:\Git_Dan\JupyterNoteBooks ----
  • Finally, right-click on the shortcut, select Copy, flip over to your Desktop and Paste it there.  
  • yes... I know you can go to the command interface and run the command line from there, but why.  You can also use Anaconda Navigator in other non-ArcGIS Pro environments.  The installation and setup of the application within the Pro environment isn't worth the extra effort.

Python runs that script, which imports notebook.notebookapp as shown below.  That import does the work of setting up notebooks to work in your target folder.

""" Source code of ---- jupyter-notebook-script.py ---- located in
:  _drive_:\_folder_\bin\Python\envs\arcgispro-py3\Scripts ... where _drive_ and _folder
:  are unique to your machine... for example
:  ---- C:\ArcPro\bin\Python\envs\arcgispro-py3\Scripts ----
"""

if __name__ == '__main__':
    import sys
    import notebook.notebookapp

    sys.exit(notebook.notebookapp.main())‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The details aren't really relevant... Just click on the shortcut, create your notebook and begin sharing... but before you do that, begin your reading here

And from a recent post... perhaps the future might look like this...

5 Comments
New Contributor III

Hey Dan Patterson, this is a great article as I'm running into this issue but after following your directions, I now get an error in ArcGIS Pro v2.3.1 when I try to update the numpy package saying that my environment was renamed to a different location - however, as you can see from the file window, the folder is still the same.   See my screenshot below. 

MVP Esteemed Contributor

Nichole do you actually have a folder called c:\programfiles ?  which is not like the windows created … C:\Program Files

Also, since you are using a clone, make sure that you set the active environment to the clone and update numpy from it.

Preferably, use conda to update packages, 

I have full control over my machine so I don't use clones, but the process of updating packages is still valid in this link

/blogs/dan_patterson/2018/12/28/clone 

New Contributor III

Nevermind - this was a different issue. Sorry.    

New Contributor III

I created a shortcut alias so my filepaths do not have a space in them to avoid issues. ArcGIS Pro is just being very glitchy and not updating python packages properly. 

MVP Esteemed Contributor

conda is the route and you can use the --dry-run option to check to see what is going to happen before hand

ie

conda update numpy --dry-run

sure beats an update causing issues with other packages

About the Author
Retired Geomatics Instructor at Carleton University. I am a forum MVP and Moderator. Current interests focus on python-based integration in GIS. See... Py... blog, my GeoNet blog...
Labels