I just started using python with Arcgis and am struggling with the basic step of importing a custom toolbox to use in my script. I've used ImportToolbox according to the documentation as such:
arcpy.ImportToolbox(r"C:\Users\matth\Documents\LAStools\LAStools\ArcGIS_toolbox\LAStools.tbx", "lastools")
in order to import the 'lastools' toolbox. I've confirmed this is the correct directory, and get the following error:
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 171, 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 464, in generate_toolbox_module
mycode = compile(code,
File "C:\Users\matth\Documents\LAStools\LAStools\ArcGIS_toolbox\LAStools.tbx", line 1141
^
SyntaxError: invalid syntax
Is there anything obvious I'm doing wrong or is potentially a problem with the toolbox? Any help is appreciated, thanks!
If the toolbox has an alias, skip the second part of the import.
ImportToolbox—ArcGIS Pro | Documentation
I tried ommitting the alias and it still gives the same issue
move the toolbox (and associated scripts if applicable) into a different/simpler folder
eg c:/tools