<?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 Re: Python tool generates an error only inside IDE in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726089#M56279</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It really is best practice to use a toolbox alias with arcpy, to avoid namespace collisions. Your IDE is probably picking up on the ambiguities of not having one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you still have a problem if you do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.CheckOutExtension("DataInteroperability")
arcpy.ImportToolbox(r"C:\GISTemp\PythonTBX.tbx", "iop")
arcpy.PythonETL_iop() # or the equilvalent, arcpy.iop.PythonETL()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 07:03:23 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-12T07:03:23Z</dc:date>
    <item>
      <title>Python tool generates an error only inside IDE</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726088#M56278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm getting a warning in Aptana writing my python code, &lt;/SPAN&gt;&lt;STRONG&gt;but the script will run&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my script (text in red is error / warning):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.CheckOutExtension("DataInteroperability")
arcpy.ImportToolbox(r"C:\GISTemp\PythonTBX")
arcpy.PythonETL()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The red text above displays the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Undefined variable from import, PythonETL&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure why the error is displaying but the script still runs... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script runs fine on its own outside of Aptana.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-m&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:51:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726088#M56278</guid>
      <dc:creator>MatthewBaker2</dc:creator>
      <dc:date>2021-12-12T16:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Python tool generates an error only inside IDE</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726089#M56279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It really is best practice to use a toolbox alias with arcpy, to avoid namespace collisions. Your IDE is probably picking up on the ambiguities of not having one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you still have a problem if you do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.CheckOutExtension("DataInteroperability")
arcpy.ImportToolbox(r"C:\GISTemp\PythonTBX.tbx", "iop")
arcpy.PythonETL_iop() # or the equilvalent, arcpy.iop.PythonETL()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:03:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726089#M56279</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-12T07:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python tool generates an error only inside IDE</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726090#M56280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Unfortunately still getting the same 'message'.... what is "iop"?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-m&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Apr 2014 16:05:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726090#M56280</guid>
      <dc:creator>MatthewBaker2</dc:creator>
      <dc:date>2014-04-25T16:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python tool generates an error only inside IDE</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726091#M56281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;what is "iop"?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"iop" is the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//03q300000086000000" rel="nofollow noopener noreferrer" target="_blank"&gt;toolbox alias or (new, better terminology) module name.&lt;/A&gt;&lt;SPAN&gt; These are used to keep namespaces from getting to cluttered, for example to differentiate arcpy.management.Clip() from arcpy.analysis.Clip().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm wondering if it's possible you have [post=369411]imported the two toolboxes with the same module name[/post] and Aptana is picking up on that. Here's a little test script I wrote to check if an module name is already loaded:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# check if an alias in the arcpy name space already
def chkalias(alias):
&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exec("arcpy.{}".format(alias))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return True
&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return False

 
&amp;gt;&amp;gt;&amp;gt; chkalias("usgs")
False
&amp;gt;&amp;gt;&amp;gt; arcpy.ImportToolbox('C:\\ArcGIS\\Desktop10.1\\ArcToolbox\\Toolboxes\\USGS EGIS Tools.tbx')
&amp;lt;module 'usgs' (built-in)&amp;gt;
&amp;gt;&amp;gt;&amp;gt; chkalias("usgs")
True
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:03:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726091#M56281</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-12T07:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python tool generates an error only inside IDE</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726092#M56282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well here's my inputs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Toolbox and Path:&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\GISTemp\PythonTBX&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Toolbox name:&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;PythonTBX&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Model Name (alias): &lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;PythonETL&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://joelmccune.com/2011/05/05/run-models-as-scheduled-tasks/" rel="nofollow noopener noreferrer" target="_blank"&gt;Joel's article &lt;/A&gt;&lt;SPAN&gt;goes into this issue as well, and from what I can see, my syntax should be (with relevant text in red):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.CheckOutExtension("DataInteroperability")
arcpy.ImportToolbox(r"&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;C:\GISTemp\PythonTBX&lt;/SPAN&gt;", "&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;PythonETL&lt;/SPAN&gt;")
arcpy.&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;Model_PythonETL&lt;/SPAN&gt;()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...which still throws the same message...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thoughts on that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-m&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:03:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726092#M56282</guid>
      <dc:creator>MatthewBaker2</dc:creator>
      <dc:date>2021-12-12T07:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python tool generates an error only inside IDE</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726093#M56283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a reason you're not using the ".tbx" file extension, like in the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//03q300000086000000" rel="nofollow noopener noreferrer" target="_blank"&gt;help &lt;/A&gt;&lt;SPAN&gt;for ImportToolbox?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for my guess about multiple, conflicting module loads, a reload() cleans that out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm assuming your toolbox module name/alias is "matt" (or - even if if it isn't, we are overriding it by specifying it in the ImporToolbox() call). I'm assuming your model name (not model alias/caption) is "Model".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;reload(arcpy)
arcpy.ImportToolbox(r"C:\GISTemp\PythonTBX.tbx", "matt")
arcpy.Model_matt()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:03:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726093#M56283</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-12T07:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python tool generates an error only inside IDE</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726094#M56284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ooops, just an oversight not using .TBX - but - doesn't seem to make a difference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would bet that Aptana is having a hard time with this message, but I wouldn't be too much more concerned at this point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for the help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-m&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 21:27:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-generates-an-error-only-inside-ide/m-p/726094#M56284</guid>
      <dc:creator>MatthewBaker2</dc:creator>
      <dc:date>2014-04-29T21:27:15Z</dc:date>
    </item>
  </channel>
</rss>

