python toolbox from Pro to Portal

10-03-2017 04:01 AM
New Contributor III


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 = [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",

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

        param1 = arcpy.Parameter(
            name = "LabelTest",

        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


    def updateMessages(self, parameters):

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

    def execute(self, parameters, messages😞

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


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 ?

Tags (3)
0 Kudos
3 Replies
MVP Esteemed Contributor

what ever environment portal runs from doesn't have that module installed

0 Kudos
New Contributor III

I know that, but how do I install those modules on the server, and witch server ?

My configuration is

  • Server1 - portal
  • Server2 - arcgis server as Federated server
  • Server3 - datastore

Now that I'm developing in Python 3.x I would like for the server to run Python 3.x so I don't have any trouble with unicode characters ect.

0 Kudos
MVP Esteemed Contributor

You may want to Move your question‌    to Python‌ since the ArcGIS API for Python is actually a different environment, which uses Jupyter Notebook  ( ArcGIS API for Python | ArcGIS for Developers )

re: getting installed on the Server....have you tried installing Pro on the server?  I would think that would get Python 3 the environment setup with the correct paths, etc., but Dan is much more knowledgeable about that than I am, so I'll defer to him/others.

0 Kudos