2

I'm running 10.4 and occasionally get an error when running scripts with the line;

mxd = arcpy.mapping.MapDocument("CURRENT")

Error message: CreateObject cannot open map document

Note "Always run in foreground" is checked and so is "Run python script in process"

When I try to run the same line of code in the ArcMap Python window, ArcMap crashes.

Anyone else having this issue?

1 Answer 1

1

I think you should first treat this as being either a corrupt mxd or a corrupt ArcMap session rather than an ArcPy problem.

I would start by closing ArcMap (rebooting too may be a good idea) and re-opening your map, then retest your code, if it gets that far.

Make sure that you have no other instances of ArcMap (or ArcCatalog) running when you do the above.

You may also need to locate and delete your Normal.mxt because you may be encountering something similar to foreground arcpy.mapping.MapDocument("CURRENT") in python script in single ArcMap produces createobject errors

1
  • Thanks. Yes, restarting ArcMap does temporarily fix the problem and I only run one instance of ArcMap at a time. I also read the link and deleted the Normal.mxt but the problem persists. Note that the problem occurs on at least two separate installs of ArcMap.
    – Ryan
    Aug 29, 2016 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.