Select to view content in your preferred language

"Object has no Attribute"the second time through arcpy script

3554
12
01-24-2012 12:23 PM
MarkBentley
Emerging Contributor
I created a toolbox that contains a few tools from the Arc Hydro Groundwater Tool Suite that I like to use in my modeling.  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:

"<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute"

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.  This cycle has proven itself to repeat indefinitely.  What could be causing this, do I need to clear something out at the end of the toolbox import?

import arcpy
arcpy.ImportToolbox("D:\GIS_Geodatabase\ES12.mdb\mytools", "mytools")
arcpy.mytools.ExportPackageWEL("WEL","CELLGRP","CBFlags","StressPeriods","DISVars","Params","D:\MODFLOW_WorkingFiles\EASTSHOR_MODFLOW\EASTSHOR.wel")
Tags (2)
0 Kudos
12 Replies
NathanHeick
Frequent Contributor
Please let me know if any of you find a clear explanation for this.  I have spent many hours the last two weeks with a similar problem.  The difference I have is that it occurs after I call the second script tool from my main script tool.  No matter how I comment out the code, the second tool call fails with AttributeErrors.  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.  Now, I get the issue when calling models from the script tool, not just script tools from the script tool.  I had concluded it has something to do with arpcy and the ImportToolbox function.  If I find something today, I will let you know.  First, I want to test Mark's workaround and understand it.  I will be so happy when this problem gets resolved.  It's ruining my weekend automation.
0 Kudos
NathanHeick
Frequent Contributor
So far, what I have found using arcpy.ListToolboxes() is that my own toolbox is no longer listed after the first script tool call.  If I add it back in, the second script tool call works.  This would explain all the behavior I have seen, but I don't see why I would have to import it twice.
0 Kudos
sofoo
by
Frequent Contributor
Thanks for the ListToolboxes/Import toolbox tip!  Was getting this error prior to adding a second Import statement:
"AttributeError: Object: Tool or environment <AddMetaTags_DMTools> not found"

One more clue to add to the thread:

what works:
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).  In addition, I and others can now run it fine when remoting into the server itself.  Which was not initially the case.

what doesn't work:
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.  So perhaps there is a permissions issue here?  We are really grasping at straws now.
0 Kudos