Python toolbox works in ArcToolbox and in Python console, but not in ArcCatalog

المشرف العام

Administrator
طاقم الإدارة
I have a set of Python tools in a Python toolbox (.pyt). They are broken into multiple files and modules and have been functioning correctly, but now I'm seeing inconsistent behavior on multiple machines.

Basically, I can run the tools from code, I can run them from the Python shell, and I can import the toolbox into ArcToolbox and run them from there. But when I browse to the toolbox in ArcCatalog, each of the tools has a red X and when I right click "Why?" it tells me:

AttributeError: 'module' object has no attribute 'Parameter' This is on the first line that references arcpy (this is toolbox_utils.py).

import arcpy def make_parameter(displayName, name, datatype, defaultValue=None, parameterType='Optional', direction='Input'): """ This method prepopulates the paramaeterType and direction parameters and leaves the setting a default value for the newly created parameter as optional. The displayName, name and datatype are the only required inputs. """ # create parameter with a few defaults param = arcpy.Parameter( displayName=displayName, name=name, datatype=datatype, parameterType=parameterType, direction=direction) # set new parameter to a default value param.value = defaultValue # return the complete parameter object return param I have tried removing the .pyc files, removing and resetting the .xml metadata files and reducing the tools to a bare minimum. If I put an empty tool in a generic toolbox with no parameters, it works. Once I try to break it into the modules (which were working just fine), I start getting this error. It's as if ArcCatalog isn't resolving the arcpy reference.

This is my structure:

arcpy_utils __init__.py toolbox_utils.py service __init__.py services.py settings.py test_services.py toolpackages __init__.py service_one.py service_two.py toolbox.pyt test_toolbox.py *.xml Toolbox.pyt looks like:

import arcpy from toolpackages.service_one import ServiceOne from toolpackages.service_two import ServiceTwo class Toolbox(object): def __init__(self): ''' Define the toolbox properties here. Do not change the name of this class. ArcGIS locates this class by name. It will not be able to find the toolbox and your toolbox will not work if you modify this. ''' self.label = 'Toolbox' self.alias = 'ABCD' # List of tool classes associated with this toolbox self.tools = [ServiceOne, ServiceTwo] The toolpackages directory contains the tool definitions, with the actual code in the services module.



أكثر...
 
أعلى