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

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Oct 7, 2016 at 17:46
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. Commented Oct 7, 2016 at 18:53
  • I am currently using ArcGIS pro 1.1. How can I check the python version of this Commented 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. Commented Oct 7, 2016 at 19:51
  • Can I directly install Python 2.7 to the ArcGIS Pro Commented 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. Commented 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()

answered Oct 7, 2016 at 18:34
8
  • My Tool box is UTD and the tool is model. Commented Oct 7, 2016 at 18:36
  • Does arcpy.UTD.model() work? Commented Oct 7, 2016 at 18:37
  • No I am getting the same error again and again 'module' object has no attribute 'Model_UTD' Commented Oct 7, 2016 at 18:38
  • Are you still calling Model_UTD in your code? Commented 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. Commented Oct 10, 2016 at 11:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.