Hello all,
I went through the guide to install the new Python API, and a few issues happened. First off I'm running ArcGIS Pro 1.4, Windows 10. I opened the Python Command Prompt, executed the commend "conda install -c esri arcgis" worked, but wasn't able to launch jupyter notebook right away. I then installed jupyter using "pip install jupyter" which worked, and I was able to open a notebook with "jupyter notebook". If I start a new Python 3 notebook or run a sample I get an error when importing the module arcgis, as shown below:
from arcgis.gis import * gis = GIS() ---------------------------------------------------------------------------ImportError Traceback (most recent call last)<ipython-input-1-bc0d972ca319> in <module>()----> 1 from arcgis.gis import * 2 gis = GIS() ImportError: No module named 'arcgis'
What am I missing?
You need to run the Jupyter notebook from the same `Python Command Prompt` in which you installed the `arcgis` package. Can you confirm this workflow works?
It looks like you tried to run it from Windows terminal and had to pip install Jupyter using it
Atma thanks for the reply. I have been doing this all from the Python Command Prompt found under the ArcGIS start menu, even the pip install.
Edited Follow up: I reinstalled the conda install -c esri arcgis and now it works. I believe there was an error on the first pass due to the folder permissions. I had to grant full access to the ArcGIS\Pro\bin\Python folder under the windows properties. It was read only with my recent upgrade to Windows 10.
Everything was working, I was able to see the map, all the cells were working fine until I tried the 'import arcgis.lyr' Error says there is no arcgis.lyr module. Also noticed there is no arcgis.tools and arcgis.viz. I have attached an image of the attributes available in arcgis module on my machine.
A side note: If you installed ArcGIS Pro for all users (installs in c:\Program Files) then you would have to run the 'PYthon command prompt' with admin privileges. The prompt warns you of this as well. If you installed for just you / current user (installs in C:\users\username\appdata..) then its not necessary. This could also be a reason for the folder permissions.
Regarding `arcgis.lyr`, the API went through a redesign between beta 3 and version 1.0 and the `lyr` and `viz` modules were removed but no functionality was dropped. You can find more information on the modules here https://developers.arcgis.com/python/guide/overview-of-the-ArcGIS-Python-API/
Thanks for following up on this thread Tony. I was able to import the arcgis module using Jupyter Notebooks after reinstalling the 'conda install -c esri arcgis' from the Python Command Prompt. Regarding the arcgis module my circumstances appear different. I originally installed Jupyter Notebooks from ArcGIS Pro (ArcGIS Pro 2.0.1, Windows 8.1). I had no problems importing the arcgis module for about a month. I was trying to solve a Jedi autocomplete problem at which point I uninstalled/reinstalled Jupyter, ipython, jedi, and Spyder from ArcGIS Pro. From this point forward I could not import the arcgis module in Jupyter.
Similar to your experience I had to grant full access to the ArcGIS\Pro\bin\Python folder under the windows properties as the first try was unsuccessful due to folder permissions.
'''1st try at reinstall'''
(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>conda
install -c esri arcgis
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment C:\Program Files\ArcGIS\Pro\bin\Pyt
hon\envs\arcgispro-py3:
The following NEW packages will be INSTALLED:
arcgis: 1.2.4-py35_1 esri
The following packages will be UPDATED:
ipywidgets: 5.1.5-py35_0 esri --> 5.2.2-py35_1
Proceed (
CondaIOError: IO error: Missing write permissions in: C:\Program Files\ArcGIS\Pr
o\bin\Python
#
# You don't appear to have the necessary permissions to install packages
# into the install area 'C:\Program Files\ArcGIS\Pro\bin\Python'.
# However you can clone this environment into your home directory and
# then make changes to it.
# This may be done using the command:
#
# $ conda create -n my_arcgispro-py3 --clone="C:\Program Files\ArcGIS\Pro\bin\Py
thon\envs\arcgispro-py3"
'''2nd try at reinstall after granting full control to Program Files\ArcGIS\Pro\bin\Python'''
(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>conda
install -c esri arcgis
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment C:\Program Files\ArcGIS\Pro\bin\Pyt
hon\envs\arcgispro-py3:
The following NEW packages will be INSTALLED:
arcgis: 1.2.4-py35_1 esri
The following packages will be UPDATED:
ipywidgets: 5.1.5-py35_0 esri --> 5.2.2-py35_1
Proceed (
Uninstalling prior versions of arcgis widget
Installing C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pa
ckages\arcgis\widgets -> arcgis
Making directory: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\shar
e\jupyter\nbextensions\arcgis\
Copying: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pack
ages\arcgis\widgets\custom.css -> C:\Program Files\ArcGIS\Pro\bin\Python\envs\ar
cgispro-py3\share\jupyter\nbextensions\arcgis\custom.css
Copying: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pack
ages\arcgis\widgets\mapview.js -> C:\Program Files\ArcGIS\Pro\bin\Python\envs\ar
cgispro-py3\share\jupyter\nbextensions\arcgis\mapview.js
Copying: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pack
ages\arcgis\widgets\__init__.py -> C:\Program Files\ArcGIS\Pro\bin\Python\envs\a
rcgispro-py3\share\jupyter\nbextensions\arcgis\__init__.py
Making directory: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\shar
e\jupyter\nbextensions\arcgis\icons
Copying: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pack
ages\arcgis\widgets\icons\marker.png -> C:\Program Files\ArcGIS\Pro\bin\Python\e
nvs\arcgispro-py3\share\jupyter\nbextensions\arcgis\icons\marker.png
Copying: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pack
ages\arcgis\widgets\icons\pink.png -> C:\Program Files\ArcGIS\Pro\bin\Python\env
s\arcgispro-py3\share\jupyter\nbextensions\arcgis\icons\pink.png
Making directory: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\shar
e\jupyter\nbextensions\arcgis\requirejs
Copying: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pack
ages\arcgis\widgets\requirejs\text.js -> C:\Program Files\ArcGIS\Pro\bin\Python\
envs\arcgispro-py3\share\jupyter\nbextensions\arcgis\requirejs\text.js
Making directory: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\shar
e\jupyter\nbextensions\arcgis\__pycache__
Copying: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-pack
ages\arcgis\widgets\__pycache__\__init__.cpython-35.pyc -> C:\Program Files\ArcG
IS\Pro\bin\Python\envs\arcgispro-py3\share\jupyter\nbextensions\arcgis\__pycache
__\__init__.cpython-35.pyc
- Validating: ok
To initialize this nbextension in the browser every time the notebook (or ot
her app) loads:
jupyter nbextension enable arcgis --py --sys-prefix
Enabling notebook extension arcgis/mapview...
- Validating: ok
I had a suspicion that the tutorial samples were out of date. Now I see, looking at the Release Notes. Thank you for your help.
The samples were updated as well. You can get the latest from here https://github.com/Esri/arcgis-python-api/releases