3

I am using arcGIS 10.0 SP5

I have the following code :

import arcpy

arcpy.ImportToolbox(r"C:\Documents and Settings\Derek\FRAME\FORTEST.tbx", "Derek")

arcpy.TEST_Derek()

The model is names TEST The toolbox alias is Derek

When I try and run this I get an error

AttributeError: 'module' object has no attribute 'TEST_Derek"

What I want to do is to run the model TEST from the toolbox FORTEST

  • 1
    When you right click on the model in the toolbox and go to properties under the general tab confirm that Name is TEST and not Label. Label is the user friendly text, Name is the Name you hook into to run the model. Also confirm your FORTEST.tbx really does have an alias called Derek. On a side note "Derek" is not a very sensible alias as it describes nothing about the toolbox... – Hornbydd Feb 26 '14 at 13:04
  • Hi. Thanks for the comment. I have checked that the name of the model is indeed called TEST and the label is also called TEST. The toolbox is called FORTEST and the label is also called FORTEST and the Alias is called Derek. I realise that it is a silly alias but it is for testing only prior to adding to a larger python script – DerekB Feb 26 '14 at 13:17
  • I have run trials using this code on arcGIS 10.1 and it runs perfectly but I am using arGIS 10.0 – DerekB Feb 26 '14 at 14:24
  • Try saving the toolbox as version 10.0 from your 10.1 machine? – Hornbydd Feb 26 '14 at 14:29
2

I agree with some of the other posts, it sounds like you at one time or another edited the model from a 10.1 machine and clicked save. Doing such would make it a v10.1 model now and unable to be opened or viewed by a v10.0 machine. The only options I know to get around this are A) Right click on the TOOLBOX (not the model) and save as a v10.0 toolbox and then run from there. B) Rebuild the model on a v10.0 machine using the same tools and parameters... seems like a waste of time, but you could do it this way. C) You could open the tool from a v10.1 machine and, if it includes no 10.1 specific functionality nor any modelbuilder specific functionality (no modelbuilder specific tools or iterators) you could try the export model to python script and then just call that python script instead of calling your model from the script you are actually writing.

What I would do is try to open the model from ArcGIS Desktop on the v10.0 machine. If you can open it correctly there and it is still having this issue, there there is something else wrong, you may want to re-check spellings, permissions issues, etc... not sure. But if it won't let you open the model from the v10.0 machine but will from the v 10.1 machine, I'm pretty sure it's a model version issue and the save toolbox as v10.0 model would work just fine (note that this may potentially do odd or unexpected things to your model if it has a lot of v10.1 specific tools or functionality....so you may want to double check it).

  • The model was created in arcGIS 10.0 and needs to run in arcGIS 10.0. I just did the test on arcGIS 10.1 to see if it would run – DerekB Feb 26 '14 at 15:01
  • 1
    Can you currently open the model from within ArcGIS Desktop v10.0 ? Also, maybe try opening a new model and copying the contents of the original model into it and save to see if it might just be the model got corrupted some how... unfortunately, this happens all too often. – John Feb 26 '14 at 15:59
1

After ImportToolBox, you can display arcpy.ListTools() and arcpy.ListToolBoxes() to see how your tool is actually defined.

  • Hi. Thanks for the help. I have run the extra code that you suggested and found out that there is no record of the tool to access. I tried the same thing using a copy of arcGIS 10.1 and the code runs perfectly. Is there something that was changed between the arc vwersions? and is there a workaround? – DerekB Feb 26 '14 at 14:31
  • I know you can right-click on a toolbox and Save As a different version. It seems opening the Toolbox with a newer version of ArcGIS, converts the Toolbox to that newer version. – klewis Feb 26 '14 at 21:57

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.