Import arcpy into Jupyter Nootebook

16271
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
JayantaPoddar
MVP Esteemed Contributor

Here is what I found.

Did you check Adding the Arcpy Path to Anaconda in https://community.esri.com/groups/spatial-data-science/blog/2016/02/11/connecting-arcpy-to-your-jupy... ?

 Also check the attachment. Hope it is helpful.



Think Location
AtmaMani
Esri Contributor

An easier way is to simply install the Python API using ArcGIS Pro's python package manager as explained here https://developers.arcgis.com/python/guide/install-and-set-up/#Install-using-ArcGIS-Pro

Then start your notebooks using the 'Python Command Prompt' that ships with Pro. You are good to go. You can import both ArcPy and the Python API.

IonutAlixandroae4
Occasional Contributor

Hi Atma,

I have tried using ArcGIS Pro and I saw that I already had arcgis package installed (version 0.1); when I tried to update it, it ran a progress bar but nothing happened, nothing updated, and I don`t know why.

After that, I opened Python command prompt of ArcGIS Pro and typed "jupyter notebook" and got an error..

Thanks,

Ionut

0 Kudos
AtmaMani
Esri Contributor

Ionut, I will send this to the Pro team to investigate. Meanwhile, can you update the package by using the Python command prompt and typing

conda upgrade -c esri arcgis

This should update the package. From the screenshot, you have installed Pro for all users, in C:\program files. Hence start the Python command prompt as an administrator.

IonutAlixandroae4
Occasional Contributor

Hi Atma,

Yes, I also think that the first problem I reported should be investigated by the Pro team, it may be a bug or something.

Also, I started Python cmd as Admin and tried to update arcgis but there`s a conflict or something and also, if I try to open jupyter notebook, I am missing some modules I think... 

If I install Anaconda 3 and also Python API, isn`t there another way to "bring" ArcGIS Pro arcpy into it?

Thanks, I really appreciate your support!

Ionut

0 Kudos
AtmaMani
Esri Contributor

Your Pro Python version is 3.4 which we don't support. Its likely you are using a very old version of Pro. Can you update your Pro to the latest? This will update the conda and Python that ship with it.

IonutAlixandroae4
Occasional Contributor

Hi Atma,

I have Pro 2.0 installed on my computer, updated via the updater window when started Pro 1.4... Python version installed with Pro is 3.5.3; Now I`m not really sure where does that 3.4 version of python comes from....

Also, In ArcGIS Pro I`m not having problems importing arcpy or arcgis

Thanks,

Ionut

0 Kudos
ClintonDow1
Occasional Contributor II

Hello Ionut,

It looks like something unusual has happened to your installation, I unfortunately can't seem to reproduce the issue so I'll give some general advice:

  • If the environment is broken, you can delete the 'arcgispro-py3' folder in %proInstall%\bin\Python\envs and rerun the installer, select 'repair installation' and it will recreate the fresh environment for you.
  • Jupyter Notebook creates shortcuts in the start menu, so may need Admin privileges to install correctly. (You should get a UAC pop-up in the Pro package manager in this case.)
  • Click the refresh button in the Pro package manager (blue circular arrows above package list) to get the latest versions of the package list. 'arcgis' is up to version 1.2.0 - there have been a few issues with packages shipped from Continuum Analytics that are outside of our control which may cause problems. (See this thread)
  • Anaconda is fairly aggressive in setting your system's PATH variable - double check that it isn't causing confusion. Its odd on the last screenshot to see Python 3.4 and 3.5 referenced on the same operation. 
  • Currently arcpy is part of the Pro folder structure and not a 'pure' package, so it is not supported to install via Anaconda. (Working on this as we speak, should be supported soon.) As per Curtis' post it is possible to do currently but I can't guarantee things will work if you choose to follow those instructions.

Hopefully that helps a bit and gets you back to a working state. If you continue to have problems let us know! 

IonutAlixandroae4
Occasional Contributor

Hi Clinton,

Thanks for the reply and your feedback!!

Trying to reply in the order you provided:

1. I have re-installed ArcGIS Pro and when I try to reinstall arcgis package, it shows the loading bar, it appears as it was installed but after I can`t find it at installed packages, it`s still at packages available to install (to add), so no install. I had 0.1 verison before re-installed and working...

2. I have admin privileges on my computer; I have installed Anaconda 3 (3.6 - 64 bits) in C:/Users/%user%/ Anaconda3; It also created a path in the environment variables on C:\Users\%user%\Anaconda3\Scripts

3. That refresh button does the refresh but still no changes when installing argis package

4. Anaconda3 has a path in env  variables

5. I`ll wait for arcpy for jupyter nootebook.

Now, the problems seems to be at installing arcgis in Pro 2.0.... 

Thanks,

Ionut

0 Kudos