AnsweredAssumed Answered

Run model from model builder in python

Question asked by ggolay123@hotmail.com on Jun 22, 2016
Latest reply on Jun 24, 2016 by dkwiens

Hi,

 

I've built a model with model builder. When I run it from model builder it works but now that i've exported it to python, it doesn't work...

 

Here is my model:

 

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("C:/Users/w2sohi/Desktop/test/box.tbx","box")

# Local variables:
INTER = "C:\\Users\\w2sohi\\Desktop\\test\\INTER"

# Process: Recréer le localisateur d’adresses
arcpy.RebuildAddressLocator_box(INTER)

 

It seems that there's a problem with: arcpy.ImportToolbox("C:/Users/w2sohi/Desktop/test/box.tbx","box")

 

I have these error messages:

 

Traceback (most recent call last):
  File "C:\Users\w2sohi\Desktop\test\recreer.py", line 13, in <module>
    arcpy.ImportToolbox("C:/Users/w2sohi/Desktop/test/box.tbx","box")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\__init__.py", line 90, in ImportToolbox
    return import_toolbox(input_file, module_name)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 441, in import_toolbox
    mymodule = generate_toolbox_module(toolbox, None, False, False, False, module_name, use_alt_alias)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 399, in generate_toolbox_module
    use_alt_alias))
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 391, in <genexpr>
    code = u"\n".join(line if isinstance(line, unicode)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 311, in code_for_toolbox
    yield "__all__ = %r" % ([str(tool.name) for tool in toolbox.tools],)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 3: ordinal not in range(128)

 

Thank you very much!

 

Guillaume

Outcomes