<?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: &amp;quot;Object has no Attribute&amp;quot;the second time through arcpy script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710306#M55071</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the ListToolboxes/Import toolbox tip!&amp;nbsp; Was getting this error prior to adding a second Import statement: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff8c00; font-style: italic;"&gt;"AttributeError: Object: Tool or environment &amp;lt;AddMetaTags_DMTools&amp;gt; not found"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more clue to add to the thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;what works: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can call the same custom toolbox twice from one python script and the script tool runs fine for me when run on my local computer, (the tool and scripts are located on an internal server in an sde sql server gdb).&amp;nbsp; In addition, I and others can now run it fine when remoting into the server itself.&amp;nbsp; Which was not initially the case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;what doesn't work: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When my co-workers run the tool (located on the same server) from their local computers, it bombs out when trying to call a second tool from the same toolbox.&amp;nbsp; So perhaps there is a permissions issue here?&amp;nbsp; We are really grasping at straws now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Dec 2013 00:31:33 GMT</pubDate>
    <dc:creator>sofoo</dc:creator>
    <dc:date>2013-12-04T00:31:33Z</dc:date>
    <item>
      <title>&amp;quot;Object has no Attribute&amp;quot;the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710294#M55059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I created a toolbox that contains a few tools from the Arc Hydro Groundwater Tool Suite that I like to use in my modeling.&amp;nbsp; The tools import alright and I can run the script once, but when I try to run the same script a second time with the same inputs I get a message saying the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; "&amp;lt;type 'exceptions.AttributeError'&amp;gt;: 'NoneType' object has no attribute"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I close Arc Map and run the script again, the script will run one time. If a try to run it twice I get the same error message as above.&amp;nbsp; This cycle has proven itself to repeat indefinitely.&amp;nbsp; What could be causing this, do I need to clear something out at the end of the toolbox import? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jan 2012 20:23:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710294#M55059</guid>
      <dc:creator>MarkBentley</dc:creator>
      <dc:date>2012-01-24T20:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710295#M55060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's a long shot, but you could try adding a try...except clause to your script - it may give you more information... Like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel")
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(2)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;This may return a little more information about the error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you also post the exact error that Python returns including line number (plus ensure the script you post is laid out identically to the one you are using); this information often is very useful, as it indicates which part of the script is failing, and possibly why.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something does just come to mind that if you import the same toolbox multiple times then it must have a different name; perhaps you could make it "mytools_1" the first time, "mytools_2" the second time, etc...? Depending on how you use your code this is probably not be easy to do...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710295#M55060</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-12T06:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710296#M55061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help on this.&amp;nbsp; The error I am receiving is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:1;"&gt;&amp;lt;type 'exceptions.AttributeError'&amp;gt;: 'NoneType' object has no attribute &lt;BR /&gt;'ExportPackageWEL_mytools'&lt;BR /&gt;Failed to execute (EastShorePermit).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I inserted the "try/except" clause like you said.&amp;nbsp; The error no longer shows, however it just skips over the section where the trouble occurs. The script I am using is pretty long, but the trouble really only occurs in the very last block of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:1;"&gt;import arcpy&lt;BR /&gt;&lt;BR /&gt;#Clears the rows in "Wells_New" and adds 1 new row&lt;BR /&gt;arcpy.AddMessage("The rows in 'Wells_New' feature class are being cleared")&lt;BR /&gt;arcpy.DeleteRows_management("Wells_New")&lt;BR /&gt;rows = arcpy.InsertCursor("Wells_New")&lt;BR /&gt;myrow = 1&lt;BR /&gt;while myrow &amp;lt;= 1:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.newRow()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myrow = myrow + 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.insertRow(row)&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;arcpy.AddMessage("The rows have been cleared")&lt;BR /&gt;&lt;BR /&gt;#Linking script parameters entered in ArcGIS to&lt;BR /&gt;#Python Parameters in this script&lt;BR /&gt;arcpy.AddMessage("Linking script parameters entered in ArcGIS to Python Parameters in this script")&lt;BR /&gt;pR = arcpy.GetParameterAsText(0)&lt;BR /&gt;sT = arcpy.GetParameterAsText(1)&lt;BR /&gt;sB = arcpy.GetParameterAsText(2)&lt;BR /&gt;K = arcpy.GetParameterAsText(3)&lt;BR /&gt;X = arcpy.GetParameterAsText(4)&lt;BR /&gt;Y = arcpy.GetParameterAsText(5)&lt;BR /&gt;arcpy.AddMessage("The parameters you entered have been linked to python parameters in the script")&lt;BR /&gt;&lt;BR /&gt;#Write the parameters to 'Wells_New'&lt;BR /&gt;arcpy.AddMessage("Write the parameters to 'Wells_New'")&lt;BR /&gt;rows = arcpy.UpdateCursor("Wells_New")&lt;BR /&gt;for row in rows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.PumpingRate = pR&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.ScreenTop = sT&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.ScreenBot = sB&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.LayerNumber = K&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.X = X&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Y = Y&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;arcpy.AddMessage("The parameters you entered are being written to the 'Wells_New' feature class")&lt;BR /&gt;&lt;BR /&gt;#Converts the Coordinates to a point&lt;BR /&gt;#Uses the SearchCursor to extract the X, Y values from "Wells_New"&lt;BR /&gt;arcpy.AddMessage("Creating Point from coordinates")&lt;BR /&gt;rows = arcpy.SearchCursor("Wells_New")&lt;BR /&gt;for row in rows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xval = row.X&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; yval = row.Y&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;&lt;BR /&gt;#Creating Point from coordinates&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;point = arcpy.Point(xval, yval)&lt;BR /&gt;pointGeo = arcpy.PointGeometry(point)&lt;BR /&gt;arcpy&lt;BR /&gt;arcpy.AddMessage("A point has been created based on the coordinates you provided")&lt;BR /&gt;&lt;BR /&gt;#Writes that point to the "SHAPE*" field in the "Wells_New" table.&lt;BR /&gt;arcpy.AddMessage("The point that was created is being assigned as the location of the new well")&lt;BR /&gt;rows = arcpy.UpdateCursor("Wells_New")&lt;BR /&gt;for row in&amp;nbsp; rows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SHAPE = pointGeo&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;arcpy.AddMessage("The location of the new well has been assigned")&lt;BR /&gt;&lt;BR /&gt;#Determine the IJ index for the well&lt;BR /&gt;#Used to help determine value of IJK&lt;BR /&gt;arcpy.AddMessage("Determining 'IJ' indice for the new well")&lt;BR /&gt;arcpy.SelectLayerByLocation_management("Cell2D","INTERSECT","Wells_New")&lt;BR /&gt;rows = arcpy.SearchCursor("Cell2D")&lt;BR /&gt;for row in rows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ijdex = row.IJ&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;arcpy.SelectLayerByAttribute_management("Cell2D", "CLEAR_SELECTION")&lt;BR /&gt;arcpy.AddMessage("The 'IJ' indice is " + str(ijdex)) &lt;BR /&gt;&lt;BR /&gt;#Determine the values of I and J seperately&lt;BR /&gt;#Used in determining IJK&lt;BR /&gt;arcpy.AddMessage("Determining the values of I and J seperately")&lt;BR /&gt;rows = arcpy.SearchCursor("CellIndex", '[IJ]='+ str(ijdex))&lt;BR /&gt;for row in rows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ival = row.I&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jval = row.J&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;arcpy.AddMessage("The value of the 'I' indice is " + str(Ival))&lt;BR /&gt;arcpy.AddMessage("The value of the 'J' indice is " + str(Jval))&lt;BR /&gt;&lt;BR /&gt;#Number of Cells in the I, J, and K directions.&lt;BR /&gt;#Used in calculation of IJK&lt;BR /&gt;numi = 67&lt;BR /&gt;numj = 36&lt;BR /&gt;numk = 3&lt;BR /&gt;&lt;BR /&gt;#Calculate the value of IJK&lt;BR /&gt;#Used for ahgw 'WEL' table&lt;BR /&gt;arcpy.AddMessage("Calculating the IJK indice")&lt;BR /&gt;K = int(K)&lt;BR /&gt;IJK = ((K - 1) * numi * numj )+(( Ival - 1 ) * numj ) + Jval&lt;BR /&gt;arcpy.AddMessage("The value of 'IJK' is " + str(IJK))&lt;BR /&gt;&lt;BR /&gt;#Create a new blank row in the well table&lt;BR /&gt;arcpy.AddMessage("Creating a new blank row in the 'WEL' table")&lt;BR /&gt;rows = arcpy.InsertCursor("WEL")&lt;BR /&gt;myrow = 1&lt;BR /&gt;while myrow &amp;lt;= 1:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = rows.newRow()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myrow = myrow + 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.insertRow(row)&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;arcpy.AddMessage("A new blank row has been created in the 'WEL' table")&lt;BR /&gt;&lt;BR /&gt;#Write the appropriate values to the "WEL" table&lt;BR /&gt;arcpy.AddMessage("Writing values to the 'WEL' table")&lt;BR /&gt;arcpy.SelectLayerByAttribute_management("WEL", "NEW_SELECTION", '&lt;Q&gt; is null')&lt;BR /&gt;rows = arcpy.UpdateCursor("WEL")&lt;BR /&gt;for row in rows:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Q = pR&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.IJK = IJK&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Writing Key Value to 'CELLGRP' field")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.CELLGRP = -1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.SPID = 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Qfact = 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.IFACE = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;BR /&gt;del row&lt;BR /&gt;del rows&lt;BR /&gt;arcpy.SelectLayerByAttribute_management("WEL","CLEAR_SELECTION")&lt;BR /&gt;arcpy.AddMessage("Values for new well have been written to the 'WEL' table")&lt;BR /&gt;&lt;BR /&gt;#Import My tool Box to use several AHGW tools&lt;BR /&gt;arcpy.AddMessage("Importing a toolbox containing several AHGW tools that will be used")&lt;BR /&gt;arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools")&lt;BR /&gt;arcpy.AddMessage("The toolbox has been imported")&lt;BR /&gt;arcpy.AddMessage("Exporting the AGHW 'WEL' table to the MODFLOW '.wel' file")&lt;BR /&gt;# The code dies somewhere in here or at least I do not see the next 'AddMessage' that I programmed in&lt;BR /&gt;arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel")&lt;BR /&gt;arcpy.AddMessage("The Table has been exported")&lt;BR /&gt;arcpy.AddMessage("Using AHGW tools to run MODFLOW")&lt;BR /&gt;arcpy.mytools.RunMODFLOW("C:\Program Files (x86)\Aquaveo\Arc Hydro Groundwater Toolkit\MF2K\mf2k_ahgw.exe", "D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.mfn")&lt;BR /&gt;arcpy.AddMessage("MODFLOW has finished")&lt;BR /&gt;arcpy.AddMessage("Importing the results of the MODFLOW model that are relevant to analysis")&lt;/Q&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jan 2012 23:41:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710296#M55061</guid>
      <dc:creator>MarkBentley</dc:creator>
      <dc:date>2012-01-24T23:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710297#M55062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The error basically says that it can't find &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;ExportPackageWEL&lt;/STRONG&gt;&lt;SPAN&gt; in the toolbox you import.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have seen this happen before; Arc actually calls the tool by its &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;name&lt;/STRONG&gt;&lt;SPAN&gt;, but what you see in ArcMap/Catalog is just a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;&lt;STRONG&gt;label&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;, not the actual &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;name &lt;/STRONG&gt;&lt;SPAN&gt;(or vice versa, I can't remember). Load the toolbox in ArcMap/Catalog and check that both name and label for that tool are set to &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;ExportPackageWEL&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if that fixes it!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jan 2012 00:36:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710297#M55062</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2012-01-25T00:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710298#M55063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Stacey,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think that is the cause of it because all of the ArcGIS tools as well as the ArcHydroGroundwater tools that I am using have different names and labels.&amp;nbsp; Also when I tried changing the name of the tools I discovered that I am not allowed to change the name or label of any of the tools that come with ArcGIS or ArcHydro Groundwater. It appears that these attributes are fixed for each tool&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did make an interesting discovery while simulating the script in the "Python Window."&amp;nbsp; When I put in my code like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:1;"&gt;arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\ExportRun" , "ExportRun")&lt;BR /&gt;arcpy.ExportRun.ExportRun()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can run the tool without error once but if I try to run it twice then I get the same error saying:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:1;"&gt;&amp;lt;type 'exceptions.AttributeError'&amp;gt;: 'NoneType' object has no attribute&lt;BR /&gt;'ExportRun_ExportRun'&lt;BR /&gt;Failed to execute (debug).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But if I change the name of the Module from "ExportRun" to "ExportRun2," I am once again able to run the tool one time without restarting ArcGIS. This means my code would now read as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:1;"&gt;arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\ExportRun" , "ExportRun2")&lt;BR /&gt;arcpy.ExportRun.ExportRun()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears that there is a restriction on ways or the number of times that I can use my module.&amp;nbsp; One Idea that I have is that I might be importing the same tools twice with the same module name.&amp;nbsp; I could see where this might cause confusion, since there would be two toolsets with the same name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jan 2012 19:01:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710298#M55063</guid>
      <dc:creator>MarkBentley</dc:creator>
      <dc:date>2012-01-26T19:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710299#M55064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can understand that occurring within the Python window in ArcMap, but it really should not happen when running scripts (everything should get deleted, or there should be a method to &lt;/SPAN&gt;&lt;STRONG&gt;unImportToolbox&lt;/STRONG&gt;&lt;SPAN&gt;)...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A way around it might be to use &lt;/SPAN&gt;&lt;STRONG&gt;ListToolboxes()&lt;/STRONG&gt;&lt;SPAN&gt; to find out if it has already been imported, like so (based upon your second post):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
if u"mytools" not in arcpy.ListToolboxes():
 arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools")
 arcpy.AddMessage("The toolbox has been imported")
else:
 arcpy.AddMessage("Toolbox already present, skipping import")
arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if that helps... If it doesn't work, try getting rid of the u in front of u"mytools" - it is just specifying that the string is a unicode string, which a lot of the Arc stuff seems to be.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:50:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710299#M55064</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-12T16:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710300#M55065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Actually, the best way to get the name (in my previous post u"mytools") would be to import the toolbox, &lt;/SPAN&gt;&lt;STRONG&gt;then &lt;/STRONG&gt;&lt;SPAN&gt;use ListToolboxes() and find it within the list so that you know what it is actually being called after it is imported (then you should be safe if Arc is using the label or name or whatever)...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jan 2012 00:02:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710300#M55065</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2012-01-27T00:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710301#M55066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello people!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have very very similar problem to the one you discuss about above. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using JPype module inside ArcGIS modelBuilder. JPype is used to use Java classes inside Python code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also run without any problems my model (only my scripts are in there, no default tools from toolbox) ONLY THE FIRST TIME and from the second time and afterwards I get the following error: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;&amp;lt;type 'exceptions.AttributeError'&amp;gt;: 'NoneType' object has no attribute '__metaclass__'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I really cannot understand what is the cause of this error. Inside my script I start the JVM and call some Java classes. After that I delete all the objects created. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know if Mark or Stacey you have found something new, or have a new idea about what may be causing trouble. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sokratis&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 11:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710301#M55066</guid>
      <dc:creator>SokratisBarmpounakis</dc:creator>
      <dc:date>2012-01-30T11:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710302#M55067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay I figured out a workaround for this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.ImportToolbox("Path to Toolbox")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.gp.Toolbox = "Path to Toolbox"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.gp.ToolName()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using this method I can import the toolbox and run it as many times as I want.&amp;nbsp; Not sure why it works though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 02:58:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710302#M55067</guid>
      <dc:creator>MarkBentley</dc:creator>
      <dc:date>2012-02-03T02:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710303#M55068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Okay I figured out a workaround for this.&lt;BR /&gt;&lt;BR /&gt;arcpy.ImportToolbox("Path to Toolbox")&lt;BR /&gt;arcpy.gp.Toolbox = "Path to Toolbox"&lt;BR /&gt;arcpy.gp.ToolName()&lt;BR /&gt;&lt;BR /&gt;Using this method I can import the toolbox and run it as many times as I want.&amp;nbsp; Not sure why it works though.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dear Mark can you somehow relate this thing you found, with my problem perhaps? I don't use the system toolbox, I am just using my own scripts imported into the ArcGIS model builder. You think our problems are somehow related?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 07:17:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710303#M55068</guid>
      <dc:creator>SokratisBarmpounakis</dc:creator>
      <dc:date>2012-02-03T07:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710304#M55069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please let me know if any of you find a clear explanation for this.&amp;nbsp; I have spent many hours the last two weeks with a similar problem.&amp;nbsp; The difference I have is that it occurs after I call the second script tool from my main script tool.&amp;nbsp; No matter how I comment out the code, the second tool call fails with AttributeErrors.&amp;nbsp; I thought I had fixed this on our development server, but when I moved our ETL toolbox to our test server, it came back more consistently than ever.&amp;nbsp; Now, I get the issue when calling models from the script tool, not just script tools from the script tool.&amp;nbsp; I had concluded it has something to do with arpcy and the ImportToolbox function.&amp;nbsp; If I find something today, I will let you know.&amp;nbsp; First, I want to test Mark's workaround and understand it.&amp;nbsp; I will be so happy when this problem gets resolved.&amp;nbsp; It's ruining my weekend automation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jun 2012 21:05:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710304#M55069</guid>
      <dc:creator>NathanHeick</dc:creator>
      <dc:date>2012-06-10T21:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710305#M55070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So far, what I have found using arcpy.ListToolboxes() is that my own toolbox is no longer listed after the first script tool call.&amp;nbsp; If I add it back in, the second script tool call works.&amp;nbsp; This would explain all the behavior I have seen, but I don't see why I would have to import it twice.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jun 2012 21:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710305#M55070</guid>
      <dc:creator>NathanHeick</dc:creator>
      <dc:date>2012-06-10T21:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: "Object has no Attribute"the second time through arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710306#M55071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the ListToolboxes/Import toolbox tip!&amp;nbsp; Was getting this error prior to adding a second Import statement: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff8c00; font-style: italic;"&gt;"AttributeError: Object: Tool or environment &amp;lt;AddMetaTags_DMTools&amp;gt; not found"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more clue to add to the thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;what works: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can call the same custom toolbox twice from one python script and the script tool runs fine for me when run on my local computer, (the tool and scripts are located on an internal server in an sde sql server gdb).&amp;nbsp; In addition, I and others can now run it fine when remoting into the server itself.&amp;nbsp; Which was not initially the case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;what doesn't work: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When my co-workers run the tool (located on the same server) from their local computers, it bombs out when trying to call a second tool from the same toolbox.&amp;nbsp; So perhaps there is a permissions issue here?&amp;nbsp; We are really grasping at straws now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 00:31:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-quot-object-has-no-attribute-amp-quot-the/m-p/710306#M55071</guid>
      <dc:creator>sofoo</dc:creator>
      <dc:date>2013-12-04T00:31:33Z</dc:date>
    </item>
  </channel>
</rss>

