I recently upgraded from ArcGIS Pro 3.1.1 to 3.4.3, which includes the latest Python API (2.4.0.1). I am working in a disconnected environment, so I'm unable to use conda/pip to re-install/repair python libraries in the default environment that is instlled with ArcGIS Pro. I believe I may have encountered a bug in the new arcgis.map.Map() class.
I previously used the now depricated WebMap class, and saved a new web map to ArcGIS Enterprise using the following snippet:
import arcgis
gis = arcgis.gis.GIS(url=<PortalURL>, username=<PortalUsername>, password=<PortalPassword>, set_active=True)
webMap = arcgis.mapping.WebMap()
#add some layers
webMapProperties = {'title':'Example Web Map', 'type':'Web Map', 'description':'Example description'}
webMapItem = webMap.save(item_properties=webMapProperties, thumbnail=<path to thumbnail>)
Since the WebMap class has been deprecated in ArcGIS Pro 3.4 / arcgis 2.4.0, I am working on updating my script to utilize the new Map class with the following snippet:
from arcgis.map import Map
gis = arcgis.gis.GIS(url=<PortalURL>, username=<PortalUsername>, password=<PortalPassword>, set_active=True)
webMap = Map()
webMapProperties = {'title':'Example Web Map', 'type':'Web Map', 'description':'Example description'}
webMapItem = webMap.save(item_properties=webMapProperties, thumbnail=<path to thumbnail>)
The documentation for the save method suggests that Map objects have a save() method, with the following sample:
new_wm_item = wm.save(webmap_item_properties, thumbnail=’./webmap_thumbnail.png’)
When I try to call the save() method on a Map object, I am getting the following ModuleNotFoundError: No module named 'arcgis._impl._content_manager'.
When I look at my Python environment, there is a "_impl" folder in "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\", but there is no "_content_manager" within the "_impl" folder.
However, "..\site-packages\arcgis\gis\_impl\_content_manager\" does exist. It looks like the API is looking in the wrong "_impl" directory to find the _content_manager class.
To make it a little more clear:
"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\_impl\_content_manager" DOES NOT EXIST
"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\_impl\_content_manager" EXISTS
Traceback (most recent call last):
File "C:\Users\me\Desktop\Atlas-Publish\atlas-publish\Installer\Installer_3x.py", line 1541, in <module>
webMapItem = webMap.save(item_properties=webMapProperties, folder=portalFolder, thumbnail=WebMapThmb)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py", line 647, in save
return self._helper.save(item_properties, thumbnail, metadata, owner, folder)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\_utils.py", line 1837, in save
elif not isinstance(folder, arcgis_cm.Folder):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\auth\tools\_lazy.py", line 49, in __getattr__
return getattr(self._load(), attrb)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\auth\tools\_lazy.py", line 45, in _load
self._mod = importlib.import_module(self._module_name)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'arcgis._impl._content_manager'
One note is that my OCD kicked in while installing the ArcGIS Pro 3.4 patches, and even though "Each patch is cumulative of all previous patch fixes", I installed 3.4.1, then 3.4.2, then the latest 3.4.3 when upgrading my ArcGIS Pro installation.
One other note is that I am running ArcGIS Enterprise 11.3. While writing up this post, I came across this page, that suggests that ArcGIS Pro 3.3 is more compatible with Enterprise 11.3. The deprecation of the WebMap class isn't present in ArcGIS Pro 3.3's default python environment (arcgis 2.3.0). I still thought this question was relevant, as it seems like a potential bug in arcgis 2.4.0.1.