AnsweredAssumed Answered

using arcpy.env.workspace to open a MXD

Question asked by jnerge on Jun 18, 2012
Latest reply on Jun 18, 2012 by jnerge
So my script was working on Friday but doesn't anymore, and I can't figure out why. Basically, I am running into an error when trying to set the environment workspace and use it to open a MXD. Here is a dumbed down version of the piece of my code that is throwing an error (it throws the same error as what's in my actual code:

import arcpy

arcpy.env.workspace = "C:/test"

mapdoc = "test.mxd"

mxd = arcpy.mapping.MapDocument(mapdoc)

and here is the error:
>>> Traceback (most recent call last):
  File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\interact.py", line 558, in OnEditExecClipboard
    exec o in __main__.__dict__
  File "<clipboard>", line 7, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__
    assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
AssertionError: Invalid MXD filename.

If I run arcpy.mapping.MapDocument("C:/test/test.mxd") it works fine, so I don't know where things are getting hung up. Please help, and thanks in advance to all for any input.

Outcomes