I have created a Toolbox (alias: mytool) and a model (name: mymodel; and it takes 2 parameters which are 'this' and 'that') with ModelBuilder. I need to execute this model from a Python script.

arcpy.mymodel_mytool(r"D:\temp\this", r"D:\temp\that")

The script runs well but didn't print anything. My question is how to check if this model has been successfully executed by printing out messages from the command prompt.

1 Answer 1


Geoprocessing tools will return a result object. If you store the result in a variable you can examine it afterwards.

result = arcpy.mymodel_mytool(r"D:\temp\this", r"D:\temp\that")

# The following will print all the messages associated with the result
print result.getMessages()

The ArcGIS resource page on Results objects lists the properties and methods you can use to examine your result. You can find the status of the tool (e.g. Succeeded/Failed), and print any error messages. http://resources.arcgis.com/en/help/main/10.1/index.html#//018z00000046000000

  • I got "AttributeError: 'Result' object has no attribute 'GetMessages'". Any idea?
    – alextc
    Commented Nov 9, 2015 at 13:12
  • @alextc - Apologies, the g is lowercase, i.e. arcpy.getMessages(). I've updated my answer with this change.
    – Ali
    Commented Nov 9, 2015 at 13:18
  • @alextc No problem!
    – Ali
    Commented Nov 9, 2015 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.