Select to view content in your preferred language

import error for arcpy.mapping module in jupyter notebook

3404
2
03-27-2019 01:03 PM
ChaudhuriGargi
New Contributor

I have using arcpy with Jupyter notebook for last few months and all the modules work fine except arcpy.mapping. Here is what happening:

When I write:

import arcpy
from arcpy import mapping
mxd = arcpy.mapping.MapDocument("R:/CourseData//Exercise1/road.mxd")

it gives me the following error:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-d75a1b04e4b6> in <module>()      
1 import arcpy
----> 2 from arcpy import mapping      
3 mxd = arcpy.mapping.MapDocument("R:/CourseData//Exercise1/road.mxd")
ImportError: cannot import name 'mapping'

When I write:

import arcpy
mxd = arcpy.mapping.MapDocument("R:/CourseData//Exercise1/road.mxd")

it gives me:

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-099b6ea15d97> in <module>()      
1 import arcpy
----> 2 mxd = arcpy.mapping.MapDocument("R:/CourseData//Exercise1/road.mxd")

AttributeError: module 'arcpy' has no attribute 'mapping'

Any thoughts?
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

sounds like you are connecting to the arcpy for ArcGIS Pro (and python 3.x) because 'mapping' is now 'mp'

Introduction to arcpy.mp—ArcPy | ArcGIS Desktop 

You will have to edit your references to the old mapping module to replicate what you can in the new mp version

ChaudhuriGargi
New Contributor

Thank you. That was helpful.

0 Kudos