如何安装不带Anaconda变体的ArcGIS API for Python

xa9qqrwz  于 2022-11-26  发布在  Python
关注(0)|答案(1)|浏览(193)

我遇到过ArcGIS api for python,它看起来很适合可视化可以生成的漂亮Map。起初我以为它只能通过ArcGIS Pro使用。然而,我遇到了这个YouTube视频和SO post,其中有很好的安装anaconda的说明。不幸的是,安装所有的Anaconda并不是快速Map渲染的最佳选择,并且我尝试使用python环境python3 -m pip install arcgis进行安装。
我已经尝试测试这个pip安装与jupyter笔记本电脑的建议,从这篇文章,但得到以下属性错误:

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_'

我不确定使用Anaconda进行安装和在单独的Python环境中进行安装之间的区别。

63lcw9qa

63lcw9qa1#

在安装了特定版本的ipywidgets后,我发现了一个关闭的issue错误,并指出了缺少属性,我能够按照测试示例中所示的方式渲染Map。以下是我在Windows 10上使用python 3.9.7和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

笔记本内容:

from arcgis.gis import GIS
my_gis = GIS()
m = my_gis.map()
m

相关问题