1

When running a simple Python script which is using ArcPy:

  • The script is hanging but only in one machine and not in another machine.

  • The two machines are VMs and have the same specifications: Windows server 2016, and we connect with RDP

  • The script is hanging only if running through command line but it is not hanging if running through IDE.

  • The script is not hanging as soon as we remove any action on the mxd object, such as mxd.save() below. I.E., if removing mxd.save() from the script below, it is not hanging anymore.

  • The "modified date" property of the MXD file does get updated

  • Only Python 2.7 is installed in the machine ("C:\Python27\ArcGIS10.6\python.exe")

  • We tried suggestions in this answer to Python script hanging forever in Pycharm with import arcpy but to no avail

  • We tried to disable AntiVirus, after looking at the ProcMon reports, but to no avail.

The script that is hanging is the below:

import arcpy
map_name = "C:/Test_Folder/Test.mxd"
mxd = arcpy.mapping.MapDocument(map_name)
mxd.save()
print("try")
del mxd
print("finally")

The screenshot of the hanging cmd window is the below:

enter image description here

Could anyone suggest any further troubleshooting to explore?

0

1 Answer 1

1

If you read the help file on MapDocument class it clearly states the parameter must be a A string that includes the full path and file name of an existing map document.

You don't define a full path and from what you are showing I can't tell if Test.mxd even exists. If it does not then I suspect its trying to default to the path where you are executing the code and getting some sort of permission problem because you should not really be writing data into c:\python27\arcgis10.6. If it does exist you have not told arcpy that it is allowed to overwrite and you do that by setting the environment settings.

1
  • Thank you for the comments. I clarified the description (it was a simplification just for explanation purposes, but I realize it was confusing, sorry about that).
    – PhilpM
    May 20, 2022 at 18:42

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.