Basic Question for

07-06-2021 09:07 PM
New Contributor

Hi, I just have a basic question with the  function while trying to follow along a simple tutorial that is a bit old. Here's the relevant code section below

# Import modules
import arcpy

# Create the map document object
aprx ="C:\Users\User\Documents\ArcGIS\Projects\MyProject2.aprx")

And this is the OS Error in question:

Traceback (most recent call last):
File "C:\Users\User\Desktop\Exercise ArcGis Python\Ex_Files_ArcGIS_Python_Scripting\Exercise Files\", line 15, in <module>
aprx ="C:\Users\User\Documents\ArcGIS\Projects\MyProject2.aprx")
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\", line 344, in __init__
self._arc_object = arcgisscripting._mapping.ArcGISProject(*gp_fixargs((aprx_path,), True))
OSError: C:\Users\User\Documents\ArcGIS\Projects\MyProject2.aprx

Not really sure what's happening here to not allow me reference the .aprx file which is what I thought the ArcGISProject() command did.

Tags (2)
0 Kudos
2 Replies
MVP Esteemed Contributor

From Windows Explorer, could you ensure that the filepath of the aprx file is correct?

Just my assumption, maybe you missed the folder containing the aprx file (e.g. "C:\Users\User\Documents\ArcGIS\Projects\MyProject2\MyProject2.aprx")

or any other pathname

Think Location
MVP Esteemed Contributor

unless you altered the path


probably should be

 C:\Users\.. your user name ...\Documents\ArcGIS\Projects\MyProject2.aprx

where  "your user name" is your identifier

... sort of retired...
0 Kudos