Select to view content in your preferred language

Cannot import 'Layer' from arcgis.mapping

867
2
Jump to solution
07-04-2023 06:03 AM
Sfortunatamente
Occasional Contributor

Hi,

I am working on a simple script which copies a web map and adds a new layer:

from arcgis.gis import GIS
from arcgis.mapping import WebMap
from arcgis.mapping import Layer

I receive:

ImportError: cannot import name 'Layer' from 'arcgis.mapping' (C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\mapping\__init__.py)

ArcGIS Pro 3.1.1

What is wrong?

Thanks.
-b.

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

There is no class Layer in arcgis.mapping .

 

Here are some classes that could be what you want:

 

for x in arcgis.mapping.__dict__.keys():
    print(x)

 

...
MapImageLayer
MapImageLayerManager
...
VectorTileLayer
...
Object3DLayer
IntegratedMeshLayer
Point3DLayer
VoxelLayer
PointCloudLayer
BuildingLayer
SceneLayer
...
MapServiceLayer
MapFeatureLayer
MapTable
MapRasterLayer
...

 

It's also possible that you actually want arcpy.mp.Layer ...

 


Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

There is no class Layer in arcgis.mapping .

 

Here are some classes that could be what you want:

 

for x in arcgis.mapping.__dict__.keys():
    print(x)

 

...
MapImageLayer
MapImageLayerManager
...
VectorTileLayer
...
Object3DLayer
IntegratedMeshLayer
Point3DLayer
VoxelLayer
PointCloudLayer
BuildingLayer
SceneLayer
...
MapServiceLayer
MapFeatureLayer
MapTable
MapRasterLayer
...

 

It's also possible that you actually want arcpy.mp.Layer ...

 


Have a great day!
Johannes
0 Kudos
Sfortunatamente
Occasional Contributor

Thanks a lot! I should be more careful with AI then..

-b.