AnsweredAssumed Answered

python toolbox from Pro to Portal

Question asked by lemvig_kommune on Oct 3, 2017
Latest reply on Oct 3, 2017 by rastrauch

Hi

I'm starting to develop som geoprocessing tools in ArcGIS Pro using some third party python modules, but even with the simpliest of tools it fails to run from Portal

 

Sample code

import arcpy
import openpyxl

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "Toolbox"
        self.alias = ""

        # List of tool classes associated with this toolbox
        self.tools = [Tool]


class Tool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):

        """Define parameter definitions"""
        param0 = arcpy.Parameter(

            displayName="Input Features",
            name="in_features",
            datatype="GPString",
            parameterType="Required",
            direction="Input")

        param0.filter.type = "ValueList"
        param0.filter.list = ['test1','test2']


        param1 = arcpy.Parameter(
            displayName="Label",
            name = "LabelTest",
            datatype="GPString",
            parameterType="Optional",
            direction="Input"
        )

        params = [param0, param1]
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):

        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        parameters[1].value = parameters[0].value

        return

    def updateMessages(self, parameters):

        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return

    def execute(self, parameters, messages):

        """The source code of the tool."""
        returnVal = parameters[0].value + ' TEST ' + parameters[1].value

        arcpy.AddWarning(returnVal)
        return

 

If I run this from Pro theres no problem and I can publish it as a webtool, no problem

But when I want to run it from portal i fails, unless I publis it without the import openpyxl line

 

So how do I get portal to use third party python modules like openpyxl ?

Outcomes