Issue
I have come across ArcGIS api for python and it looks great for visualizing nice maps that can be generated. At first I thought it was only available through ArcGIS Pro. However, I have come across this YouTube video and SO post with great instructions to install with anaconda. Unfortunately, installing all of Anaconda is not the best option for speedy map renderings, and I tried to install with an python environment python3 -m pip install arcgis
.
I have tried testing this pip install with jupyter notebook as suggested from this post, but get the following Attribute Error:
from arcgis.gis import GIS
my_gis = GIS()
m = my_gis.map()
m
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~\LocationVenues\py_venv\lib\site-packages\IPython\core\formatters.py:920, in IPythonDisplayFormatter.__call__(self, obj)
918 method = get_real_method(obj, self.print_method)
919 if method is not None:
--> 920 method()
921 return True
File ~\LocationVenues\py_venv\lib\site-packages\arcgis\widgets\_mapview\_mapview.py:948, in MapView._ipython_display_(self)
942 """Override the parent ipython display function that is called
943 whenever is displayed in the notebook. Display a blank area
944 below the map widget that can be controlled via a display handler
945 set to self._preview_image_display_handler.
946 """
947 self._setup_gis_properties(self.gis)
--> 948 super(MapView, self)._ipython_display_()
949 self._preview_image_display_handler = display(
950 HTML(self._assemble_img_preview_html_str("")),
951 display_id="preview-" + str(self._uuid),
952 )
953 self._preview_html_embed_display_handler = display(
954 HTML(self._assemble_html_embed_html_str("")),
955 display_id="preview-html-" + str(self._uuid),
956 )
AttributeError: 'super' object has no attribute '_ipython_display_'
I'm unsure of the distinction between installing using Anaconda and doing so in a separate Python environment.
Solution
After installing a specific version of ipywidgets, I was able to render the map as shown in the test example after finding a closed issue for the error stating the missing attribute. The following are my steps with python 3.9.7 on Windows 10 with PowerShell:
PS C:\Users\kyrlon\Desktop> python -m venv py_venv
(py_venv) PS C:\Users\kyrlon\Desktop>.\py_venv\Scripts\activate
(py_venv) PS C:\Users\kyrlon\Desktop> python -m pip install --upgrade pip
(py_venv) PS C:\Users\kyrlon\Desktop> python -m pip install ipywidgets==7.6.0
(py_venv) PS C:\Users\kyrlon\Desktop> python -m pip install arcgis
(py_venv) PS C:\Users\kyrlon\Desktop> jupyter notebook
Notebook contents:
from arcgis.gis import GIS
my_gis = GIS()
m = my_gis.map()
m
Answered By - kyrlon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.