I am very new to Python. I created a simple tool using Model Builder that updates a few columns of data in a SDE feature class. The model runs perfectly within ArcMap 10.5. I need this script to run automatically each night, and so I need a Python script to use in Windows Task Scheduler. Rather than exporting the model to a Python script from Model Builder (which I am aware does not always do a good job translating), I want to simply ask the script to run the tool. I researched and attempted the 'ImportToolbox' function, but continue to get runtime/syntax errors. I am not experienced enough to resolve what is going wrong. I have tried different aliases, removing the alias altogether...nothing has eliminated the errors. I am hoping someone will be able to point out where I may have gone wrong...

>>> import arcpy
Runtime error 
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\__init__.py", line 125, in ImportToolbox
    return import_toolbox(input_file, module_name)
  File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\toolbox_code.py", line 457, in import_toolbox
    mymodule = generate_toolbox_module(toolbox, None, False, False, False, module_name, use_alt_alias)
  File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\toolbox_code.py", line 432, in generate_toolbox_module
  File "G:\tools\SIBToolbox.tbx", line 11
    def LaneClosureUpdate.tbx():
SyntaxError: invalid syntax
  • Welcome to GIS SE, have you tried the ImportToolbox statement without the second parameter module_name
    – artwork21
    Mar 4 '20 at 13:32
  • Thank you for such a prompt response @artwork21! If you are referring to removing the alias parameter, then yes. I have tried to run it both with and without that and the result is the same. The runtime error message concludes with a syntax error as well, and I have no idea what it doesn't like.
    – K_Beach
    Mar 4 '20 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.