Hi
I have a number of ArcMap map packages (.mpk files) that I need to import into ArcGIS Pro. I am using ArcGIS Pro 2.8.3 and want to use Python to import the .mpk files to save time. I have read on the ESRI Help at https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm that I can use ImportDocument to import ArcMap map (.mxd), globe (.3dd) and scene (.sxd) files into ArcGIS Pro. However, there is no mention of ArcMap map packages (.mpk files). I tried to test if importDocument will import a .mpk file using the code provided in ArcGISPro Example 1 listed on the page but I obtained an error message.
The code I have used is:
import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
aprx.importDocument(r"C:\1\uMDM_Sanitation_Plan_2021\Sorting_Data\Boston Scheme1.mpk")
aprx.defaultGeodatabase = r"C:\1\uMDM_Sanitation_Plan_2021\uMDMData.gdb"
aprx.saveACopy(r"C:\1\uMDM_Sanitation_Plan_2021\uMDM_SpatialPlanning.aprx")
The error message obtained reads as follows:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 235, in importDocument
return convertArcObjectToPythonObject(self._arc_object.importDocument(*gp_fixargs((document_path, include_layout, reuse_existing_maps), True)))
OSError: C:\1\uMDM_Sanitation_Plan_2021\Sorting_Data\Boston Scheme1.mpk
I am new in using Python so I could be making a mistake in how I have entered the code.
Do you know how to import .mpk files into ArcGIS Pro using Python?
Thank you.
Regards,
Alka