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
-
1Welcome 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– Midavalo ♦2016年10月07日 18:53:44 +00:00Commented Oct 7, 2016 at 18:53
-
I am currently using ArcGIS pro 1.1. How can I check the python version of thisRohit Venkat Gandhi Mendadhala– Rohit Venkat Gandhi Mendadhala2016年10月07日 19:40:23 +00:00Commented Oct 7, 2016 at 19:40
-
1With ArcGIS Pro 1.1 you have to install python separately. From version 1.3 onward python is install as part of Pro.Midavalo– Midavalo ♦2016年10月07日 19:51:41 +00:00Commented Oct 7, 2016 at 19:51
-
Can I directly install Python 2.7 to the ArcGIS ProRohit Venkat Gandhi Mendadhala– Rohit Venkat Gandhi Mendadhala2016年10月07日 19:58:34 +00:00Commented Oct 7, 2016 at 19:58
-
1No 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– Midavalo ♦2016年10月07日 19:59:51 +00:00Commented Oct 7, 2016 at 19:59
1 Answer 1
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()
-
My Tool box is UTD and the tool is model.Rohit Venkat Gandhi Mendadhala– Rohit Venkat Gandhi Mendadhala2016年10月07日 18:36:21 +00:00Commented Oct 7, 2016 at 18:36
-
-
No I am getting the same error again and again 'module' object has no attribute 'Model_UTD'Rohit Venkat Gandhi Mendadhala– Rohit Venkat Gandhi Mendadhala2016年10月07日 18:38:20 +00:00Commented Oct 7, 2016 at 18:38
-
Are you still calling
Model_UTD
in your code?Evan– Evan2016年10月07日 18:39:21 +00:00Commented Oct 7, 2016 at 18:39 -
1For reference, @Evan is referring to the alternate form, by which you can use
arcpy.TBAlias.model_name()
instead ofarcpy.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.Evil Genius– Evil Genius2016年10月10日 11:45:52 +00:00Commented Oct 10, 2016 at 11:45