Select to view content in your preferred language

Why is my ArcGIS pro script causing an error in a Arcmap toolbox?

157
3
a week ago
rescobar
Regular Contributor

I have complex script that causes an error for only one user, which appears to have to do with an Arcmap toolbox. It says this an error in line 15 of my module, but that line is just a parameter which triggers other parts of the script: 

critical_hab_start = arcpy.GetParameterAsText(11)

There are several locations where table excel is used and they use the format for pro - to my knowledge. Is there anything else to look for that might cause the script to try to access the arcmap toolbox? 

    if intersect_req == "YES":
        rows = [row for row in arcpy.da.SearchCursor("neartab",['NEAR_DIST'], "NEAR_DIST = 0")]
        count1 = len(rows)
        if count1 == 0:
            prefix = "none_"
            arcpy.conversion.TableToExcel("neartab", outputfolder + r"\\"+prefix+resource_type+"no_interfx.xls")

 

arcpy.conversion.TableToExcel(stats, outputfolder + r"\\"+prefix+"_BCR"+"_"+resource_type+"fx.xls")

 

 

 

error.jpg

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

how long is the file path? it may be exceeding limits


... sort of retired...
0 Kudos
DavidSolari
MVP Regular Contributor

Shot in the dark: Does changing arcpy.conversion.TableToExcel to arcpy.TableToExcel_conversion fix the issue? As a hacksaw fix you can try checking the Python version and if it's 3 then pop any ArcMap paths in sys.path to unlink the old environment.

0 Kudos
MarcoBoeringa
MVP Alum

Looking at the error message, and as you also noticed, your script somehow manages to trigger a call to an ArcMap toolbox and scripts. 

Since ArcMap uses Python 2, and ArcGIS Pro uses Python 3, that is almost garantueed not to work (nor would this work with any other non-ESRI applications utilizing Python).

You really need to update your workflow/scripts/toolboxes to Python 3, and make sure you are no longer using ArcMap based toolchains in Pro, unless you decide to upgrade them to Python 3.

You can upgrade Python 2 based scripts and toolboxes that were intially created in ArcMap to be compatible with Python 3 and ArcGIS Pro by changing the Python code. ESRI has documentation highlighting the needed changes.

It is even possible - and I have successfully maintained such toolbox for years - to modify an ArcMap based toolbox to be able to run in both ArcMap and ArcGIS Pro. Ran beautifully in both applications after making the required changes and make the code both Python 2/3 compatible, and carefully avoiding incompatibilities between the apps.

It is perfectly doable, but you will need to invest work, no other choice...

0 Kudos