I've been fighting with a problem where I could not package one of my tools as a geoprocessing package. After lots of trial and error I found that it was connected to a totally innocuous try/except in my code. When the try/except is in the code (see below - for illustration purposes only), the publishing fails with an error message that provides no clue. I noticed at some point that if I highlight the problem tool in the Catalog then click Properties -> Parameters I get this message
When I remove the try/except, I can view the properties OK, and more importantly the publish works. I'm not a python expert so maybe there is a good explanation about how a try statement like that could have such a side effect - I'd love to hear it.
For my tool I was able to do some recoding and get around the problem. But if you are having trouble with publishing, perhaps a good test is to make sure the tools parameters are viewable via the tool properties.
import arcpy
class Toolbox(object):
def __init__(self):
self.label = "Toolbox"
self.alias = ""
self.tools = [TestBoolean]
class TestBoolean(object):
def __init__(self):
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
layer = arcpy.Parameter(displayName="Feature Layer",
name="layer",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input")
checkbox = arcpy.Parameter(displayName="Checkbox",
name="checkbox",
datatype="GPBoolean",
parameterType="Required",
direction="Input")
checkbox.value = False
params = [layer, checkbox]
for param in params:
try:
filter_list = str(param.filter.list)
except Exception:
filter_list = 'Can not access'
return params
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
return
I'm running this on ArcPro 2.4.3 and Python 3.6.8 and Advanced license.