[GIS] Jupyter and ArcGIS error: arcpy needs to run within an active ArcGIS Conda environment

anacondaarcgis-proarcpyjupyter notebook

I have installed ArcGIS Pro 1.3 and Anaconda 4.2.0 (in that order). I then followed the instructions from ESRI on Adding the ArcPy Path to Anaconda which made Jupyter find the arcpy module but I get error:

>>import arcpy

arcpy must be run from inside the Conda environment, which ArcGIS
uses to manage the installation of Python.
You can access this environment by launching Python from the links inside the
"ArcGIS > ArcGIS Pro" Start Menu Group:
    "Python Interactive Terminal" starts a Python session.
    "Python Command Prompt" opens a Command Prompt window initialized with Conda.

Or by running the proenv.bat file in the terminal:
     C:\> C:\Program Files\ArcGIS\Pro\bin\python\scripts\proenv.bat 



---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-50d283eebbb3> in <module>()
----> 1 import arcpy

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py in <module>()
     62 """.format(install_dir)
     63     print(msg)
---> 64     raise ImportError("arcpy needs to run within an active ArcGIS Conda environment")
     65 
     66 from arcpy.geoprocessing import gp

ImportError: arcpy needs to run within an active ArcGIS Conda environment

How can I get ArcPy to work in Jupyter Notebook?

Best Answer

This is how i got it to work on a new computer (i did not know of ArcGIS Package Manager when i did this):

  1. Install ArcGIS Pro (i use version 2.0.1) in a folder so the path have no whitespaces, for example C:\Program123\ArcGIS
  2. Start windows cmd prompt. Navigate to C:\Program123\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 (using cd Program123 etc...)
  3. Execute the commands below in this folder (the python.exe is located here)
  4. python -m pip install --upgrade pip
  5. python -m pip install jupyter
  6. Reboot
  7. I then have to start it with C:\Program123\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Scripts\jupyter-notebook.exe

I can now use arcpy from jupyter

Related Question