<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python tool works in PyCharm and Terminal, but not in ArcMap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-tool-works-in-pycharm-and-terminal-but-not/m-p/354718#M27905</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a Python tool that runs fine when executed from PyCharm and DOS-terminals, but fails when I execute it from ArcMap 10, SP5.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Stripped down version of the code looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;try: &amp;nbsp;&amp;nbsp;&amp;nbsp; toolbox_file = os.path.join(arcpy.gp.getMyToolboxesPath(), "MyTools.tbx") &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportToolbox(toolbox_file, "SomeTools") &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SomeTools.IRAPToESRIVector(.........) except Exception, e: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Trying to get some sensible error messages: " + e.message) &amp;nbsp;&amp;nbsp;&amp;nbsp; msg = arcpy.GetMessages(2) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("messages: " + msg)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The output looks like this, with some chinese garble:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Start Time: Tue Feb 12 12:46:07 2013&lt;BR /&gt;Running script ToESRIVectorScript...&lt;BR /&gt;Importing toolbox: C:\Users\path\to\MyTools.tbx&lt;BR /&gt;Processing C:\Users\myself\testdata\p.2.16\File1.irp&lt;BR /&gt;Trying to get some sensible error messages: Object: Tool or environment &amp;lt;?????????????????????????????????&amp;gt; not found&lt;BR /&gt;messages: &lt;BR /&gt;Completed script ToESRIVectorScript...&lt;BR /&gt;Failed to execute (ToESRIVectorScript).&lt;BR /&gt;Failed at Tue Feb 12 12:46:09 2013 (Elapsed Time: 2,00 seconds)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you can see, arcpy.GetMessages(2) returns nothing at all, while the exception states that something chinese is not found.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This resembles corrupted memory... anybody had similar issues ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Feb 2013 10:18:38 GMT</pubDate>
    <dc:creator>ØyvindIdland</dc:creator>
    <dc:date>2013-02-12T10:18:38Z</dc:date>
    <item>
      <title>Python tool works in PyCharm and Terminal, but not in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-works-in-pycharm-and-terminal-but-not/m-p/354718#M27905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a Python tool that runs fine when executed from PyCharm and DOS-terminals, but fails when I execute it from ArcMap 10, SP5.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Stripped down version of the code looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;try: &amp;nbsp;&amp;nbsp;&amp;nbsp; toolbox_file = os.path.join(arcpy.gp.getMyToolboxesPath(), "MyTools.tbx") &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportToolbox(toolbox_file, "SomeTools") &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SomeTools.IRAPToESRIVector(.........) except Exception, e: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Trying to get some sensible error messages: " + e.message) &amp;nbsp;&amp;nbsp;&amp;nbsp; msg = arcpy.GetMessages(2) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("messages: " + msg)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The output looks like this, with some chinese garble:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Start Time: Tue Feb 12 12:46:07 2013&lt;BR /&gt;Running script ToESRIVectorScript...&lt;BR /&gt;Importing toolbox: C:\Users\path\to\MyTools.tbx&lt;BR /&gt;Processing C:\Users\myself\testdata\p.2.16\File1.irp&lt;BR /&gt;Trying to get some sensible error messages: Object: Tool or environment &amp;lt;?????????????????????????????????&amp;gt; not found&lt;BR /&gt;messages: &lt;BR /&gt;Completed script ToESRIVectorScript...&lt;BR /&gt;Failed to execute (ToESRIVectorScript).&lt;BR /&gt;Failed at Tue Feb 12 12:46:09 2013 (Elapsed Time: 2,00 seconds)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you can see, arcpy.GetMessages(2) returns nothing at all, while the exception states that something chinese is not found.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This resembles corrupted memory... anybody had similar issues ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Feb 2013 10:18:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-works-in-pycharm-and-terminal-but-not/m-p/354718#M27905</guid>
      <dc:creator>ØyvindIdland</dc:creator>
      <dc:date>2013-02-12T10:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python tool works in PyCharm and Terminal, but not in ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-works-in-pycharm-and-terminal-but-not/m-p/354719#M27906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, found the issue. First I wrote some code to list available tools in my toolbox:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; toolbox_file = 'C:\Users\path\to\MyTools.tbx' &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Importing toolbox: ' + toolbox_file) &amp;nbsp;&amp;nbsp;&amp;nbsp; tbx = arcpy.ImportToolbox(toolbox_file) &amp;nbsp;&amp;nbsp;&amp;nbsp; if tbx is None: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("Toolbox is null") &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("debug: listing tools") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools = arcpy.ListTools("*MyGISTools*") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Number of tools found: %i" % len(tools)) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for tool in tools: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.Usage(tool))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again: when running this in a terminal window (DOS/CMD), or in my IDE (PyCharm), I get a list of all the tools (13 total)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But, when running this in ArcMap, I got a bunch of these:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Method ToESRIRasterScript_MyGisTools not found. Choices: Method ToESRIRasterScript_MyGisTools not unique, please use ToolboxName_ToolName.&lt;BR /&gt;Method ToIRAPVectorScript_MyGisTools not found. Choices: Method ToIRAPVectorScript_MyGisTools not unique, please use ToolboxName_ToolName.&lt;BR /&gt;Method ToESRIVectorScript_MyGisTools not found. Choices: Method ToESRIVectorScript_MyGisTools not unique, please use ToolboxName_ToolName.&lt;BR /&gt;....&lt;BR /&gt;....&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which seems to point to something being duplicated. I removed the toolbox from ArcToolbox.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, when executing it again from the Catalog window, everything worked just fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The chinese random garble must be a bug.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 07:02:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-works-in-pycharm-and-terminal-but-not/m-p/354719#M27906</guid>
      <dc:creator>ØyvindIdland</dc:creator>
      <dc:date>2013-02-14T07:02:59Z</dc:date>
    </item>
  </channel>
</rss>

