I need to create a Web Processing service on GeoServer (2.11.2) that triggers a back-end Python script. This script should be able to utilize requests and other packages necessary to do the job.

I have got the wps extension and all necessary GeoScript plugins installed with GeoServer.

I followed an example as below to create a custom script that can be called from the Admin Web Console WPS Request Builder.


import math, sys
from geoserver.wps import process
from geoscript.geom import Point
from geoscript.feature import Feature
from geoscript.layer import Layer

  title = 'Distance and Bearing',
  description = 'Computes Cartesian distance and bearing from features to an origin.' + str(sys.executable),
  inputs = {
    'origin': (Point, 'Origin from which to calculate distance and bearing.'), 
    'features': (Layer, 'Features to which distance and bearing should be calculated.')
  outputs = {
    'result': (Layer, 'Features with calculated distance and bearing attributes.')
def run(origin, features):

  for f in features.features():
    p = f.geom.centroid
    d = p.distance(origin)
    b = 90 - math.degrees(math.atan2(p.y - origin.y, p.x - origin.x))

    yield Feature({'point': p, 'distance': d, 'bearing': b})

I tried to use Python's sys library and print out sys.executable as a testing process, but the output was NoneType.

I also tried to import requests but the GeoServer logs showed requests cannot be found.

I am wondering whether arbitrary Python packages e.g. Requests can be used in a script as such supported by GeoServer WPS. Are there any limitations for Python scripts that can be triggered as Web Processing Service by GeoServer?

1 Answer 1


GeoServer does not run your OS Python, but uses Jython instead, a Java version of the same language.

That comes with its own set of ported libraries and abilities. Learn more about it here: http://www.jython.org/

Btw, the GeoServer scripting module is shipping with Jython 2.5.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.