We migrated our servers to cloud and it is causing issues with Python scripts.
Our scripts which have following statement hangs when run from Task Scheduler or Command prompt.
If I run it from IDLE, it completes fine. It only hangs in a command prompt & scheduled task.
This issue is on all servers migrated to Cloud. I uninstalled/re-installed ArcGIS desktop 10.6 but still same issue.
Have anyone experienced this issue?
Check if the user you are running the script as (if you are using one) is an admin on the server; Check if the arcpy license is active for that user while not logged in. One issue I had was trying to import another script using 'from <folder> import <module>. Worked in the IDE, but in the task scheduler it failed. Had to use just import <module> for it to work in the task.
You can run some test tasks to get exceptions as well to help troubleshooting.
try: import arcpy from arcpy import env import os import sys from datetime import datetime as dt from datetime import date, timedelta from subprocess import Popen, PIPE ... try other things except Exception as err: # write the err to a log f = open(os.path.join(r'c:\Tasks.txt'), "a") f.write(err.message) f.close()
Thanks Jeff for your response. The user I am using is admin also the arcpy license is active.
I checked the script using 'from <folder> import <module>' and 'import <module>'. The script behavior is same in both cases , it just hangs and does not exit from the command prompt.
The script is not failing, there is no error , it just not existing from the command prompt and python.exe session remains active unless I kill it forcefully or from task manager.
Comment out all of your imports and go one by one uncommenting them and see if any hang. That is how I discovered arcpy wasn't licensed and how the syntax import syntax was not acceptable to tasks scheduler.