Select to view content in your preferred language

arcgis.layers module not working

830
6
01-07-2025 09:43 AM
tad
by
Occasional Contributor

Hi,

I'm trying to add an image service to a map. I'm following documentation (https://developers.arcgis.com/python/latest/guide/using-imagery-layers/) that says to use the arcgis.layers module, but I get the following error: ModuleNotFoundError: No module named 'arcgis.layers'

I'm using ArcGIS Pro 3.2, I cloned and updated the active environment...still not found. Any suggestions would be appreciated.

Thanks.

6 Replies
CodyPatterson
MVP Regular Contributor

Hey @tad 

Are you importing the arcgis.layers module?

CodyPatterson_0-1736273480116.png

Cody

 

0 Kudos
tad
by
Occasional Contributor

Yes, @CodyPatterson  that's what is causing the error I'm receiving. Sorry, I should have made that more clear...

0 Kudos
DanPatterson
MVP Esteemed Contributor

arcgis 2.4 requires python  >3.10 <3.13

doesn't Pro 3.2 use 3.9?

give this a try

import arcgis
arcgis.__version__
'2.4.0'

from arcgis import layers

dir(layers)
['BasemapService',
 'BasemapServices',
 'BuildingLayer',
 'CSVLayer',
 'EnterpriseMapImageLayerManager',
 'EnterpriseSceneLayerManager',
 'EnterpriseVectorTileLayerManager',
.... snip ...

maybe the clone installed a different versin and "layers" is now a separate module


... sort of retired...
0 Kudos
tad
by
Occasional Contributor

Thanks @DanPatterson. That still didn't work. If it's retired, is there a new (or different) way of adding an image web service?

0 Kudos
DanPatterson
MVP Esteemed Contributor

its npt retired ... I am

so you are aren't using Pro 3.4 and python 3.11 and the cloning of the environment wouldn't have installed the correct version of the arcgis module, and even if you did install it, you will have to check that is the correct version in the clone


... sort of retired...
0 Kudos
HannesBrandt
Occasional Contributor

Hey all,

I ran into the same problem using ArcGIS PRO 3.3.5 (arcgis 2.3.0.4) and this two import variants:

import arcgis.layers
from arcgis import layers


It seems that the arcgis.layers module is simply not part of this arcgis version?

It's just not mentioned in the documentation [1], which is a bit problematic.

 

In the OGC examples [2], a different approach is mentioned, but this does not work with this version either.

from arcgis.mapping.layers import WMTSLayer, WMSLayer

 


[1] https://developers.arcgis.com/python/latest/api-reference/arcgis.layers.toc.html 

[2] https://developers.arcgis.com/python/latest/samples/publish-ogc-services/#connect-to-your-gis 


regards,
Hannes

0 Kudos