Hi, I'm having a problem where I run a custom Python script. It works when I run it in ArcGIS Pro, but it fails when I run it as a scheduled geoprocessing tool.
The relevant lines of code:
# Local variables:
# Input and Output Directories
Project = sys.argv[1]
outPath = sys.argv[2]
sourceMap = sys.argv[3]
FGDB = sys.argv[4]
Shapefile = sys.argv[5]
Coord = sys.argv[6]
# Create name for backup GDB
startName = sourceMap
mapName = startName.replace(" ", "_")
today = datetime.date.today()
date = today.strftime("%Y%m%d")
name = mapName + "_Backup_" + str(date) + ".gdb"
# Create the GDB for the output feature classes
arcpy.CreateFileGDB_management(outPath, name)
This last line above is line 53.
The error message I get is:
File "#####", line 53, in <module>
arcpy.CreateFileGDB_management(outPath, name)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 24891, in CreateFileGDB
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 24888, in CreateFileGDB
retval = convertArcObjectToPythonObject(gp.CreateFileGDB_management(*gp_fixargs((out_folder_path, out_name, out_version), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000816: The tool is not valid.
Failed to execute (CreateFileGDB).
When I run it in ArcGIS Pro as a script tool, it runs no problem. Here are my tool parameters:
What is the difference between the script succeeding in creating an out path name when running in Pro, versus running as a scheduled tool? I've tried choosing the output location in different places, including on the C drive, and making sure there are no hyphens in the path, but that doesn't seem to make a difference.
Someone please point this out to me!
Haven't written much code lately, but i remember having issues like this when i exported a script from GEO
P tools. Maybe outside of the Pro environment the script doesn't know your parameter locations..
Schedule geoprocessing tools—ArcGIS Pro | Documentation
000816: The tool is not valid.—ArcGIS Pro | Documentation
The latter lists the possible reason for the tool failure and methods to correct it