Skip to main content
5 of 7
deleted 173 characters in body
PhilpM
  • 53
  • 1
  • 6

Python ArcPy script hanging only when running through command line in a machine

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.
  • 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.
  • 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 = "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?

PhilpM
  • 53
  • 1
  • 6