I am attempting to execute a script mulitple times from the ArcMap python window (using different parameters that are hardcoded into the file).
The script runs the first time successfully, however it seems to "break" the python console, and other attempts at execfile are unsuccessful afterwards, until I restart arcgis.
Here's the a basic scenario:
- Start ArcGIS, open python console, type:
execfile(r"C:\Users\xxx\Desktop\test.py")
Script executes successfully
Modify test.py script
Type execfile(r"C:\Users\xxx\Desktop\test.py")
Python console returns to prompt
Any ideas on what might be happening? Workarounds?
2 Answers 2
I was not able to reproduce this using my test.py script which started as:
print "Test worked!"
and in your step 3 was modified to:
print "Test2 worked!"
When I ran it from the Python window using ArcGIS Desktop 10.5 and your method I got:
>>> execfile(r"C:\Temp\test.py")
Test worked!
>>> execfile(r"C:\Temp\test.py")
Test2 worked!
>>>
-
Thanks for the test, I would like to specify that the above used to work for me too. However at one point I started facing the issues I describe in the postjohnmarkovich– johnmarkovich2017年02月22日 11:26:23 +00:00Commented Feb 22, 2017 at 11:26
-
I suspect the expedient, if restarting ArcMap does not resolve it, may be to uninstall/reinstall - it sounds like something has gone astray with your configuration.2017年02月22日 11:28:50 +00:00Commented Feb 22, 2017 at 11:28
While restarting ArcMap did not resolve the issue, a full reboot brought it back to working state.
print "Test worked!"
? What do you "modify" in step 3?print "Test2 worked!"
, would I see the same symptoms?execfile
instead ofimport
and calling functions, or the more ArcGISy way of using a script tool?