Hello,
We recently used ArcPro model builder to design a pretty simple script that truncates a feature classes, then pulls data from an Excel with Lat and Long fields, makes an XY Event Layer, then appends the results of the XY layer to the truncated feature class. This model ran successfully, and once we exported it to a Python script it runs successfully with Idle 2.7, but not with 3.7.
The failure occurs when trying to access the Excel file (I think), which is strange that an older version of Python can get there, but not the same version that the script was built in. Here is the error: ERROR 000732: XY Table: Dataset <dataset> does not exist or is not supported
And the script:
Failed to execute (MakeXYEventLayer)
# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2022-12-22 09:50:37
"""
import arcpy
def PORModel(): # POR_Model
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True
PORAddresses_ = "\\\\ep-netapp2\groups$\\Police\\Investigations\\POR\\PORAddresses.xls\\PORAddresses$"
epgdb_POLICE_POR_Locations = "M:\\IT\\GIS Maps_Projects\\Police\\PORMapping\\..\\..\\..\\ConnectionStrings\\Police.sde\\epgdb.POLICE.POR_Locations"
# Process: Make XY Event Layer (Make XY Event Layer) (management)
PORAddresses_Layer = "PORAddresses$_Layer"
arcpy.management.MakeXYEventLayer(table=PORAddresses_, in_x_field="Long", in_y_field="Lat", out_layer=PORAddresses_Layer, spatial_reference="GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision", in_z_field="")
# Process: Truncate Table (Truncate Table) (management)
epgdb_POLICE_POR_Locations_2_ = arcpy.management.TruncateTable(in_table=epgdb_POLICE_POR_Locations)[0]
# Process: Append (Append) (management)
epgdb_POLICE_POR_Locations_4_ = arcpy.management.Append(inputs=[PORAddresses_Layer], target=epgdb_POLICE_POR_Locations_2_, schema_type="NO_TEST", field_mapping="Name \"Name\" true true false 255 Text 0 0,First,#,PORAddresses$_Layer,Name,0,255;Address \"Address\" true true false 255 Text 0 0,First,#,PORAddresses$_Layer,Address,0,255;Level_Status \"Level Status\" true true false 255 Text 0 0,First,#,PORAddresses$_Layer,Level_Status,0,255;Case_Number \"Case Number\" true true false 255 Text 0 0,First,#,PORAddresses$_Layer,Case_Number,0,255;Lat \"Lat\" true true false 8 Double 8 38,First,#,PORAddresses$_Layer,Lat,-1,-1;Long \"Long\" true true false 8 Double 8 38,First,#,PORAddresses$_Layer,Long,-1,-1;DOB \"Date of Birth\" true true false 8 Date 0 0,First,#,PORAddresses$_Layer,DOB,-1,-1", subtype="")[0]
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(scratchWorkspace=r"M:\IT\GIS Maps_Projects\Police\PORMapping\PORMapping_Working.gdb", workspace=r"M:\IT\GIS Maps_Projects\Police\PORMapping\PORMapping_Working.gdb"):
PORModel()
print ("Script Successful")
The Excel is on a mapped network drive, which I've occasionally had trouble hitting with other scripts, but Idle 2.7 seems to access it correctly.
other notes: We also have Python 3.9 installed. Tried to run it with Idle3.9 and get the error ModuleNotFoundError: No module named 'arcpy'
Ran AnalyzeToolsForPro and it output No Problems
Solved! Go to Solution.
Update: The machine running the script did not have the MS Access driver installed. I'm unclear why that would have not stopped Python 2.7 from completing the script, but it solved the 3.7 issue.
Update: The machine running the script did not have the MS Access driver installed. I'm unclear why that would have not stopped Python 2.7 from completing the script, but it solved the 3.7 issue.