Select to view content in your preferred language

ImportError: cannot import name 'WebMap' from 'arcgis.mapping'

1108
4
10-22-2024 12:30 PM
sandra555
Occasional Contributor

I am running a similar program from my local computer's terminal and from an AWS EC2. 

They both start with:

from arcgis.gis import *
from arcgis.mapping import WebMap

From my local computer, the code continues past the import and runs fine.

From the AWS EC2, I get the following error:

from arcgis.mapping import WebMap
ImportError: cannot import name 'WebMap' from 'arcgis.mapping' (/home/ec2-user/miniconda3/envs/env2/lib/python3.12/site-packages/arcgis/mapping/__init__.py)

I am running an Anaconda terminal locally and miniconda in my EC2.

I used "conda install -c esri arcgis" in both.

Any idea why this is happening and how to fix it?

Thanks

4 Replies
sandra555
Occasional Contributor

I think I have found the issue. The working environment is running arcgis 2.3.1 and the non-working one is running 2.4.0. From here https://www.esri.com/arcgis-blog/products/api-python/announcements/whats-new-in-arcgis-api-for-pytho... it appears that "The previous arcgis.mapping and arcgis.widgets modules have been deprecated and refactored into the new arcgis.map module." I have not tested yet, but this sounds like it could be the cause of the error.

chris_del101
Occasional Contributor

Did U solve this? Looks like it is deprecated https://developers.arcgis.com/python/latest/guide/deprecation-notices/#arcgismapping-module-1 and for me 100% does not work.

arcgis.map.Map works but doesn't look like it's the exact same, and all the docs use WebMap.

0 Kudos
sandra555
Occasional Contributor

Hi, It is definitely the version of arcgis. For now, I made a python 3.9 environment and continued using arcgis 2.3.1 so I did not have to update my code (I was not able to use arcgis 2.3.1 with python 3.12).

chris_del101
Occasional Contributor

Thanks for the info. For my own recordkeeping I thought I'd note I found some docs on this here: https://developers.arcgis.com/python/latest/guide/working-with-web-maps-and-web-scenes/#creating-a-m...