Hi everyone,
I'm doing some work converting some models from ModelBuilder into (better functioning) python scripts. To give me a framework, I've exported the model as a .py to give me an idea as to what I should be doing with my own code. One of my tools requires me to use the ImportToolbox arcpy command to bring in the Arc Hydro Tools Pro toolbox. The path is correct and the toolbox import works fine when in ModelBuilder and the tools themselves work just fine manually in Arc Pro. But when running the same command with the same parameters I get the following error:
Traceback (most recent call last):
File "C:/Users/[USERNAME]/PycharmProjects/pythonProject/HandModel.py", line 8, in <module>
arcpy.ImportToolbox(r"C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\toolboxes\Arc_Hydro_Tools_Pro.tbx")
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 185, in ImportToolbox
return import_toolbox(input_file, module_name)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\toolbox_code.py", line 491, in import_toolbox
mymodule = generate_toolbox_module(toolbox, None, False, False, False, module_name, use_alt_alias)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\toolbox_code.py", line 466, in generate_toolbox_module
'exec')
File "C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\toolboxes\Arc_Hydro_Tools_Pro.tbx", line 6403
100000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision""""
^
SyntaxError: EOL while scanning string literal
Process finished with exit code 1
I have tried both:
arcpy.AddToolbox(r"C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\toolboxes\Arc_Hydro_Tools_Pro.tbx")
arcpy.ImportToolbox(r"C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\toolboxes\Arc_Hydro_Tools_Pro.tbx")
and both yield the same error. Likewise, I have tried using regular strings with double slashes in case the raw string was tripping it up. My novice eye seems to think that there's some type of quote mismatch inside the toolbox itself, but if that's the case I wouldn't know how to fix it.
In terms of versions, I'm using Python 3.7.10, ArcHydro Pro 2.8.6, and ArcGIS Pro 2.8.2. This error occurred on ArcHydro Pro versions 2.6.2 and 2.8.6.
If anyone has any ideas as to what's going on, please feel free to chime in! I'm pretty new to this kind of scripting so I'm pretty lost. Thanks!