ERROR
It is common to employ ModelBuilder to help automate a time-consuming process. The model may need to run afterhours as a scheduled task, and to do that, a Python script is needed:
import arcpy arcpy.ImportToolbox(r"path\to\toolbox.tbx") arcpy.ModelName_ToolboxAlias()Usually, this executes without error. However, the code may raise an AttributeError such as:
'module' object has no attribute 'ModelName_ToolboxAlias'or
Object: Tool or environment <> not found.
Calling a model through Python may raise an AttributeError because of one of the following:
import arcpy arcpy.ImportToolbox(r"path\to\toolbox.tbx") arcpy.ToolboxAlias.ModelName()The error differs slightly, which helps to find the exact object Python cannot find.
Note: Models that are newly created, as well as any models that have been edited and saved in ModelBuilder in ArcGIS Pro, cannot be used in other ArcGIS for Desktop applications. Therefore, attempts to call a model created in ArcGIS Pro with the ArcPy in Python 2.7, will raise an AttributeError. See: ModelBuilder: Migration to ArcGIS Pro
Article ID: 000014511
Get help from ArcGIS experts
Download the Esri Support App
You can also download the app to access the chatbot anytime! Download it now.