Why can't I see print text when running a script in ArcMap, but can view it when run in the python window of ArcMap?

I have a number of scripts that have a print function but don't show when run from the Toolbox.



BTW, recommended practice is to use arcpy.AddMessage() rather than print, for portability between command line/batch files and ArcMap. But print is fine if you don't want your message to display inside ArcMap.

Getting print statements in Python script to print through a batch file

  • and arcpy.AddWarning() and arcpy.AddError() - they all have their uses. You would/could use print() for debug information that you only want to show when running in python window (or on command line), the print() and arcpy.AddMessage() show in the python window but only the arcpy.AddMessage/Warning/Error will show in the geoprocessing tool window. – Michael Stimson Apr 17 '15 at 2:40
  • I think this answer, including the quote from an earlier Q&A, is astray. I mostly agree with @MichaelMiles-Stimson but "arcpy.AddMessage() show in the python window" did not sound right to me so I tested to confirm my suspicion. I use arcpy.AddMessage() when I want to see a message in the geoprocessing progress dialog and/or in the JSON returned by geoprocessing services in response to REST API requests but print everywhere else. – PolyGeo Apr 19 '15 at 8:04
  • @PolyGeo, I don't know about REST/JSON.. I don't do web (we all have to have limits and there are plenty of more capable developers that do web), I use print() for debug info and AddMessage (etc) as I generally use command line for testing (sometimes it's worth doing find & replace print with #print to turn it off); there is another level above that using open(DebugFile,'a') then writing strings to it, but again I don't know how that would work with web applications. – Michael Stimson Apr 19 '15 at 22:59

Your Answer

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

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