1

enter image description hereWhen I am trying to run the following code

import arcpy
from arcpy import env
env.workspace = r"C:\Users\Rvg296\PycharmProjects\Lab6"
tbx=r"C:\Users\Rvg296\PycharmProjects\Lab6\UTD.tbx"
arcpy.ImportToolbox(tbx)
arcpy.Model_UTD()
print("Suitable areas file created")
arcpy.RemoveToolbox(tbx)

for making a model run and create shapefile in the output folder. I am receiving an error like

C:\Python27\ArcGIS10.3\python.exe C:/Users/Rvg296/PycharmProjects/Lab6/Lab6HW.py Traceback (most recent call last): File "C:/Users/Rvg296/PycharmProjects/Lab6/Lab6HW.py", line 16, in arcpy.Model_UTD() AttributeError: 'module' object has no attribute 'Model_UTD'

Process finished with exit code 1

5
  • 1
    Welcome to GIS SE! As a new user please take the tour. Your screenshot shows a model in ArcGIS Pro, yet your python error is reporting ArcGIS 10.3. ArcGIS Pro uses a different version of Python and accesses some parts of arcpy and tools differently. You need to test using ArcGIS Pro's install of python.
    – Midavalo
    Oct 7, 2016 at 18:53
  • I am currently using ArcGIS pro 1.1. How can I check the python version of this Oct 7, 2016 at 19:40
  • 1
    With ArcGIS Pro 1.1 you have to install python separately. From version 1.3 onward python is install as part of Pro.
    – Midavalo
    Oct 7, 2016 at 19:51
  • Can I directly install Python 2.7 to the ArcGIS Pro Oct 7, 2016 at 19:58
  • 1
    No you cannot. ArcGIS Pro uses Python 3.4 and its own version of arcpy. It is different to Python 2.7 and Desktop 10.3's arcpy. You'll need to install arcpy and python for ArcGIS Pro.
    – Midavalo
    Oct 7, 2016 at 19:59

1 Answer 1

3

Add the name of the toolbox you're importing as the second parameter.

If your toolbox is called UTD the import would be arcpy.ImportToolbox(tbx, 'UTD')

Then you can call your function with arcpy.UTD.Model_UTD()

8
  • My Tool box is UTD and the tool is model. Oct 7, 2016 at 18:36
  • Does arcpy.UTD.model() work?
    – Evan
    Oct 7, 2016 at 18:37
  • No I am getting the same error again and again 'module' object has no attribute 'Model_UTD' Oct 7, 2016 at 18:38
  • Are you still calling Model_UTD in your code?
    – Evan
    Oct 7, 2016 at 18:39
  • 1
    For reference, @Evan is referring to the alternate form, by which you can use arcpy.TBAlias.model_name() instead of arcpy.model_name_TBAlias(). This is documented here under Tool Organization in ArcPY: "All tools are available as functions on ArcPy but are also available in modules matching the toolbox alias name." Also, have you actually tried this solution? The toolbox name and alias are not the same thing. Oct 10, 2016 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.