Python Script in ArcGIS Pro runs correctly, but outside of Pro does not?

1283
6
10-19-2022 04:57 PM
GarrettJohnson
New Contributor III

 

 

import arcpy

def FPA(): # Features as Polygons Append

# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True

GISDB_DBO_RoadCenterlines_PartialWork = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterlines_PartialWork"
GISDB_DBO_RoadCenterline = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterline"
GISDB_DBO_RoadCenterlines_PartialWork_Polygon = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterlines_PartialWork_Polygon"
GISDB_DATAOWNER_Paved_Areas = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DATAOWNER.Paved_Areas"
GISDB_DBO_RoadCenterline_Polygon = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterline_Polygon"
GISDB_DBO_FeaturesAsPolygons = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.FeaturesAsPolygons"

# Process: Delete Field (Delete Field) (management)
GISDB_DBO_RoadCenterlines_PartialWork_2_ = arcpy.management.DeleteField(in_table=GISDB_DBO_RoadCenterlines_PartialWork, drop_field=["fullname"], method="DELETE_FIELDS")[0]

# Process: Join Field (Join Field) (management)
GISDB_DBO_RoadCenterlines_PartialWork_3_ = arcpy.management.JoinField(in_data=GISDB_DBO_RoadCenterlines_PartialWork_2_, in_field="CenterlineID", join_table=GISDB_DBO_RoadCenterline, join_field="centerlineid", fields=["fullname"], fm_option="NOT_USE_FM", field_mapping="")[0]

# Process: Graphic Buffer (2) (Graphic Buffer) (analysis)
RoadCenterline_GraphicBuffer1 = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer2"
arcpy.analysis.GraphicBuffer(in_features=GISDB_DBO_RoadCenterlines_PartialWork_3_, out_feature_class=RoadCenterline_GraphicBuffer1, buffer_distance_or_field="20 FeetInt", line_caps="ROUND", line_joins="MITER", miter_limit=10, max_deviation="0 Meters")

# Process: Delete Rows (3) (Delete Rows) (management)
Updated_Input_With_Rows_Removed_3_ = arcpy.management.DeleteRows(in_rows=GISDB_DBO_RoadCenterlines_PartialWork_Polygon)[0]

# Process: Append (2) (Append) (management)
GISDB_DBO_RoadCenterlines_PartialWork_Polygon_3_ = arcpy.management.Append(inputs=[RoadCenterline_GraphicBuffer1], target=Updated_Input_With_Rows_Removed_3_, schema_type="TEST", field_mapping="", subtype="", expression="")[0]

# Process: Graphic Buffer (Graphic Buffer) (analysis)
RoadCenterline_GraphicBuffer = "\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer"
arcpy.analysis.GraphicBuffer(in_features=GISDB_DBO_RoadCenterline, out_feature_class=RoadCenterline_GraphicBuffer, buffer_distance_or_field="20 FeetInt", line_caps="ROUND", line_joins="MITER", miter_limit=10, max_deviation="0 Meters")

# Process: Delete Rows (2) (Delete Rows) (management)
Updated_Input_With_Rows_Removed_2_ = arcpy.management.DeleteRows(in_rows=GISDB_DBO_RoadCenterline_Polygon)[0]

# Process: Append (Append) (management)
GISDB_DBO_RoadCenterline_Polygon_2_ = arcpy.management.Append(inputs=[RoadCenterline_GraphicBuffer], target=Updated_Input_With_Rows_Removed_2_, schema_type="NO_TEST", field_mapping="centerlineid \"Centerline ID\" true true false 20 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,centerlineid,0,20;rclnguid \"NENA Global ID\" true true false 254 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,rclnguid,0,254;discrpagid \"Discrepancy Agency ID\" true true false 75 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,discrpagid,0,75;rangeprefixleft \"Left Address Number Prefix\" true true false 15 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,rangeprefixleft,0,15;fromleft \"Left From Address\" true true false 4 Long 0 10,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,fromleft,-1,-1;toleft \"Left To Address\" true true false 4 Long 0 10,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,toleft,-1,-1;parityleft \"Parity Left\" true true false 1 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,parityleft,0,1;rangeprefixright \"Right Address Number Prefix\" true true false 15 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,rangeprefixright,0,15;fromright \"Right From Address\" true true false 4 Long 0 10,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,fromright,-1,-1;toright \"Right To Address\" true true false 4 Long 0 10,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,toright,-1,-1;parityright \"Parity Right\" true true false 1 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,parityright,0,1;fullname \"Full Road Name\" true true false 300 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,fullname,0,300;fedroute \"Federal Route\" true true false 10 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,fedroute,0,10;fedrtetype \"Federal Route Type\" true true false 20 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,fedrtetype,0,20;afedrte \"Alternate Federal Route\" true true false 10 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,afedrte,0,10;afedrtetype \"Alternate Federal Route Type\" true true false 20 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,afedrtetype,0,20;stroute \"State Route\" true true false 10 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,stroute,0,10;strtetype \"State Route Type\" true true false 20 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,strtetype,0,20;astrte \"Alternate State Route\" true true false 10 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,astrte,0,10;astrtetype \"Alternate State Route Type\" true true false 20 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,astrtetype,0,20;ctyroute \"County Route\" true true false 10 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,ctyroute,0,10;onewaydir \"One Way Indicator\" true true false 10 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,onewaydir,0,10;roadlevel \"Above or Below Grade\" true true false 4 Long 0 10,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,roadlevel,-1,-1;inwater \"In Water\" true true false 5 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,inwater,0,5;roadclass \"Road Class\" true true false 20 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,roadclass,0,20;countryleft \"Country on Left\" true true false 2 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,countryleft,0,2;countryright \"Country on Right\" true true false 2 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,countryright,0,2;stateleft \"State on Left\" true true false 2 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,stateleft,0,2;stateright \"State on Right\" true true false 2 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,stateright,0,2;countyleft \"County on Left\" true true false 40 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,countyleft,0,40;countyright \"County on Right\" true true false 40 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,countyright,0,40;munileft \"Municipality on Left\" true true false 100 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,munileft,0,100;muniright \"Municipality on Right\" true true false 100 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,muniright,0,100;zipleft \"Zip on Left\" true true false 5 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,zipleft,0,5;zipright \"Zip on Right\" true true false 5 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,zipright,0,5;msagleft \"MSAG on Left\" true true false 35 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,msagleft,0,35;msagright \"MSAG on Right\" true true false 35 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,msagright,0,35;esnleft \"ESN on Left\" true true false 5 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,esnleft,0,5;esnright \"ESN on Right\" true true false 5 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,esnright,0,5;OwnedBy \"OwnedBy\" true true false 50 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,OwnedBy,0,50;created_user \"created_user\" true true false 255 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,created_user,0,255;created_date \"created_date\" true true false 8 Date 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,created_date,-1,-1;last_edited_user \"last_edited_user\" true true false 255 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,last_edited_user,0,255;last_edited_date \"last_edited_date\" true true false 8 Date 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,last_edited_date,-1,-1;JoinID \"JoinID\" true true false 100 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,JoinID,0,100;BUFF_DIST \"BUFF_DIST\" true true false 8 Double 8 38,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,BUFF_DIST,-1,-1;ORIG_FID \"ORIG_FID\" true true false 4 Long 0 10,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,ORIG_FID,-1,-1;FeatureTypeID \"FeatureTypeID\" true true false 255 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\BridgeXY\\PWProjectData.gdb\\RoadCenterline_GraphicBuffer,FeatureTypeID,0,255", subtype="", expression="")[0]

# Process: Delete Rows (Delete Rows) (management)
Updated_Input_With_Rows_Removed = arcpy.management.DeleteRows(in_rows=GISDB_DBO_FeaturesAsPolygons)[0]

# Process: Append (3) (Append) (management)
GISDB_DBO_FeaturesAsPolygons_3_ = arcpy.management.Append(inputs=[GISDB_DBO_RoadCenterlines_PartialWork_Polygon_3_, GISDB_DATAOWNER_Paved_Areas, GISDB_DBO_RoadCenterline_Polygon_2_], target=Updated_Input_With_Rows_Removed, schema_type="NO_TEST", field_mapping="FeatureTypeID \"Feature Type ID\" true true false 255 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterlines_PartialWork_Polygon,FeatureTypeID,0,255,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DATAOWNER.Paved_Areas,FeatureTypeID,0,255,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterline_Polygon,FeatureTypeID,0,255;FeatureID \"Feature ID\" true true false 255 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterlines_PartialWork_Polygon,PartialWorkID,0,255,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DATAOWNER.Paved_Areas,PavedAreaID,0,255,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterline_Polygon,centerlineid,0,20;FeatureName \"Feature Name\" true true false 255 Text 0 0,First,#,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterlines_PartialWork_Polygon,fullname,0,300,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DATAOWNER.Paved_Areas,PavedAreaName,0,255,\\\\lims-gis-03\\ElementsProProjects\\Ggee_PWProjectJan2022\\GISAdmin_LIMSSQL.sde\\GISDB.DBO.RoadCenterline_Polygon,fullname,0,300;FeatureDescription \"Feature Description\" true true false 500 Text 0 0,First,#", subtype="", expression="")[0]

if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(scratchWorkspace=r"\\lims-gis-03\ElementsProProjects\Ggee_PWProjectJan2022\BridgeXY\PWProjectData.gdb", workspace=r"\\lims-gis-03\ElementsProProjects\Ggee_PWProjectJan2022\BridgeXY\PWProjectData.gdb"):
FPA()

 

 

Hello,

We are trying to run a python script daily at 3am to clean up and append data.  The Python Script above runs fine within Pro, but when trying to run it via Task Scheduler via .bat file it is not working. Any advice or info will be much appreciated.

Thank you!

Code Above:

 

Tags (3)
0 Kudos
6 Replies
graeme_hill
New Contributor III

Have you tried launching the bat file via the command window (cmd.exe) to see what errors you receive?

Also make sure you bat file matches the content here Run stand-alone scripts—ArcGIS Pro | Documentation For example

 

c:\Progra~1\ArcGIS\Pro\bin\Python\scripts\propy.bat my_script.py

 

  or

 

c:\Progra~1\ArcGIS\Pro\bin\Python\envs\[active environment default is arcgispro-py3]\python.exe my_script.py

 

p.s. can you also post code using the insert code sample under the expand toolbar button in the post text editor.

 

 

Cheers, Graeme
GarrettJohnson
New Contributor III

Thank you very much for the help!!  I posted the code using the insert code sample as you mentioned and thank you for this also as I did not know this was an option.  Thank you also for the help on running stand alone script!

I tried to run the stand alone script as you stated via CMD.

First time I tried to run with the python code located on my Desktop  and then tried with the python code in the same location as propy.bat file. Two examples below with error shown.

(arcgispro-py3) C:\>C:\Progra~1\ArcGIS\Pro\bin\Python\Scripts>propy.bat c:\users\gjohnson\desktop\RoadsPython8.29.py
'C:\Progra~1\ArcGIS\Pro\bin\Python\Scripts' is not recognized as an internal or external command,
operable program or batch file.

(arcgispro-py3) C:\>C:\Progra~1\ArcGIS\Pro\bin\Python\Scripts>propy.bat RoadsPython8.29.py
'C:\Progra~1\ArcGIS\Pro\bin\Python\Scripts' is not recognized as an internal or external command,
operable program or batch file.

Then opened up a Python CMD prompt from Start ArcGIS Python Command Prompt.

It looks like script ran correctly from the below:

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>c:\users\gjohnson\desktop\RoadsPython8.29.py

Also tried this formatting in Admin CMD prompt

C:\Windows\System32\cmd.exe /k "C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat" c:\users\gjohnson\desktop\RoadsPython8.29.py

The Python Enviroment

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>

I still needed to put in the location of the .py file at this prompt for it to run correctly.

I guess I am not sure now what to put in notepad to save as a .bat that will launch this python correctly from Task Scheduler?  Sorry for the fairly inane questions, but really appreciative the help! (Below showing successful running)

AdminCMD_PythonEnviroment.PNG

 

I may be getting closer to the issue.

Just ran test Bat file as shown in image:

TestBatFile.PNGGot the errors below so possibly a license issue of some kind?

GarrettJohnson_0-1666304361841.png

Found that the license issue above is probally from not logging into Pro with same account recently (It is a server) so I logged into pro and tried the same .bat file.  After about a min the following errors came back that I am looking into.

GarrettJohnson_1-1666305089343.png

 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

To both improve your own troubleshooting and get better feedback from Community members, focus on creating and sharing a Minimal, Reproducible Example (MRE):  How to create a Minimal, Reproducible Example - Help Center - Stack Overflow.  Having an MRE is also most helpful when opening cases with Esri Support.

GarrettJohnson
New Contributor III

Thank you on the info on MRE creation!  I will look into it and really appreciate your time and suggestion.

0 Kudos
graeme_hill
New Contributor III

There are a few things to consider when running python scripts on a server as a scheduled task:

  • who's account is the task running under? does the account have access/permission to everything required, eg a service account might not have permission to read/write to network file stores?
  • sde connection file, is it using windows or saved credentials, related to point above
  • arcgis pro licence, if named user then regular sign in to portal/arcgis online will be required (weekly) or offline licence

My bat files look like this and have worked for years

c:\Progra~1\ArcGIS\Pro\bin\Python\scripts\propy.bat "C:\scripts\hasInspection.py"

I suggest getting the python working correctly inside Pro (use Python window) on the server using the user account that the task will run under, you can use geoprocessing history in Pro to review errors.

Cheers, Graeme
GarrettJohnson
New Contributor III

Thank you for the advice and info! 

0 Kudos