Import arcpy into Jupyter Nootebook

22473
29
07-26-2017 02:22 AM
IonutAlixandroae4
Occasional Contributor

Hi,

I have 3 versions of Python installed on my machine, 1st (v 2.7) which came with ArcMap 10.5, 2nd (v 3.5) which came with ArcGIS Pro and 3rd (v 3.6) which came with Anaconda 3 (for using Jupyter Nooteboks). 

Now, in my notebooks I can use arcgis python API but I also want to use arcpy modules from ArcGIS Pro. Is there a workflow for this setup or some steps to take ?

Thanks,

Ionut

29 Replies
ClintonDow1
Occasional Contributor II

Jupyter is awesome and I enjoy using it, but I wouldn't call it an IDE. An IDE will typically include things like build automation tools, utilities to interact with the underlying file system, built in debugging and so on. Jupyter is an excellent tool for rapid data exploration, creating presentations/documents with embedded code and for creating websites that display real-time data. When building a full Python application then an IDE such as PyCharm or Visual Studio will be more suitable for your needs. Some Python IDEs include an .ipynb editor (such as PyCharm) which allow you to view notebooks as well. 

ModyBuchbinder
Esri Regular Contributor

Hello all

Reading this form and https://community.esri.com/thread/191758-how-to-run-python-with-the-arcgis-pro-14-from-outside and some of Dan's blogs makes me very confused.

We use Jupiter notebook as main python environment because it has good interface with some other products we use (not GIS). We would like to "import arcpy" and work just like we do in IDLE or pyscripter. We have Pro 2.0 installed (and ArcMap).

Our machines are NOT connected to the web so we need to understand exactly what we need to download and install.

Can somebody summarize the easiest way? Is Pro 2.1 will make it better?

Thanks

0 Kudos
IonutAlixandroae4
Occasional Contributor

Hi Mody,

Well, this was kinda the question I asked; about a specific transitional workflow to be able to use ArcPy and Python API both in a desktop IDE or ArcMap/ArcGIS Pro and also in Jupyter Notebooks; but it is a bit confusing especially because there are different versions of python used for  ArcMap (2.7), ArcGIS Pro(3.5) and Anaconda 3 for Jupyter Notebooks (3.6); for me, I haven`t been able to use them together. 

I can only use Python API in JUpyter (without ArcPy), and ArcPy in ArcMap/ArcGIS Pro (without Python API).

Hopefully in the near future I will be able to install some upgrades or something to integrate them.

Thanks,

Ionut

0 Kudos
ShaunWalbridge
Esri Regular Contributor

If you install Pro 2.1, it ships with both Jupyter and the ArcGIS API for Python in its default environment -- everything should work out of the box. You can also create environments from the Python backstage (Project > Python), and install packages from that location, without needing the command line. The start menu group for Pro includes a shortcut for Jupyter which you can use directly, or you can invoke it by running "Python Command Prompt", then typing jupyter notebook.

Let me know if that isn't clear, or you need any additional guidance. If you're using Pro, you shouldn't need to have a separate Conda install for the Python API at this time, and Pro 2.1 ships with Python 3.6, so you'll be in alignment on that front.

Cheers,

Shaun

IonutAlixandroae4
Occasional Contributor

Hi Shaun,

Yup. with Pro 2.1 everything resolved  

Thanks a lot !

curtvprice
MVP Esteemed Contributor

Shaun, do you need admin access to get this anaconda functionality as you did in previous versions?

0 Kudos
ShaunWalbridge
Esri Regular Contributor

Replying to an ancient thread at this point, but wanted to confirm that you don't need admin access at Pro 2.2. There are still some growing pains around since since you now need to clone, but in the long run this should provide a beneficial pattern to users, and anyone can install and add packages, not just administrators.

simoxu
by MVP Regular Contributor
MVP Regular Contributor

To use ArcPy and ArcGIS API for Python together, there is one question inevitable:

How to exchange data between two APIs?

Data Exchange Between ArcPy and ArcGIS API for Python 

0 Kudos
XinhLe
by
New Contributor

I just use pip to install archook package. It's working for me, simple and fast. I found this recently and very happy with it.

Just open the Jupyter notebook you want to work with, type in:

! pip install archook  #this will find and install archook

then type in these to call arcpy to work in your Jupyter notebook.

import archook

archook.get_arcpy()

import arcpy

Note: My anaconda is 32 bit, python 2. I tried and it worked in ArcGIS version 10.6 and 10.5 for me. I'm not sure for other versions. 

Import Arcpy from Anaconda Jupyter Notebook_Easy and Super Quick way_save 2018 Sep - YouTube 

0 Kudos
ShaunWalbridge
Esri Regular Contributor

Unfortunately, archook hasn't been updated to work with ArcGIS Pro -- hopefully it will soon. We're also looking at other ways we can make this pattern work better in the future.

0 Kudos