The previous setup of pywps is outdated as it was based on old versions of the WPS 1.0.0 implementation. WPS2.0.0 was launched early 2018. But there are still a lot of applications to be found based on WPS1.0.0 implemented by PyWPS. Here a very short manual with thanks to Maarten Pronk (Deltares) for an easy installation, the former one causes a lot of stress.
Step 1 Install Anaconda
Start with installing Anaconda for Python2.7. Recepies for WPS2 implemented by PyWPS4 on Linux using Python 3.6 will be published later on this year. In the meantime it is advised to port your scripts to Python 3.
Step 1 Install Anaconda
Start with installing Anaconda for Python2.7.
The following packages are required and can be installed via Conda and pip.
Code Block | ||||
---|---|---|---|---|
| ||||
conda install lxml=3.5.* gdal=1.10.* -c conda-forge
pip install pywps==3.2.6 --no-deps
pip install python-magic |
Note! This has to be done using a command prompt opened as administrator.
Following steps can be done in any matterorder.
Step 2 Configure PyWPS
- Create a folder called c:\pypws
- Create a folder called
c:\pywps\pywps_processes
processes
Download https://github.com/geopython/pywps/archive/pywps-3.2.6.zip
- Extract Add the file
default.cfg
from the zip (in pywps
) as pywps.cfg in the c:\pywps folder - [optional] Extract the files from the pywps/processes folder to c:\pywps\pywpsprocesses to have dummy wps processes for testing
- [optional] Personalize pywps.cfg with your information
- Set correct path variables in pywps.cfg) into it. If you like you can insert your own information in the file.
However, do not forget to :- Set the correct path for
under [server] section.tempPath(
c:/pywps/
temp) - Set
outputPath
under [server] section.(
c:/[webserver]/htdocs/wps/wpsoutput
) - Set
processesPath
toc:/pywps/pywps_processes
- Set the
logFile
to somewhere(
c:/pywps/wps.log
)
- Set the correct path for
The path slashes should conform to python conventions, which happen to be the same as the linux slash convention, and not the windows convention. Note that python paths should never end with a slash!
...
#!C:\program files\anaconda2\python.exe import sys sys.path.insert( 0 , r "C:/pywps" ) import os os.environ[ 'PYWPS_CFG' ]= 'C:/pywps/pywps_processes/default.cfg' os.environ[ 'MPLCONFIGDIR' ]= 'C:/Python27/Lib/site-packages/matplotlib/mpl-data' # Note that WPS runs as apache user and not as you, so many more user variables might be needed. # Restart Apache after adding one. import wps |
Step 4 First test of WPS
Test your WPS by starting Apache server and navigate to http://localhost/cgi-bin/pywps.cgi The result should be something similar to this, meaning that the pywps process runs correctly inside the apache web server.
http://localhost/cgi-bin/pywps.cgi
<ExceptionReport xmlns= "http://www.opengis.net/ows/1.1" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" version= "1.0.0" xsi:schemaLocation= "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd" > <Exception exceptionCode= "NoApplicableCode" > <ExceptionText> 'No query string found.' </ExceptionText> </Exception> </ExceptionReport> |
Step 5 Testing WPS behavior
Now pywps runs, test for correct WPS behavior in browser using the syntax in WPS Primer. In c:\pywps\tests\processes
some example processes are included, copy its entire contents to the c:\pywps\pywps_processes
folder (that you configured as processesPath=c:/pywps/pywps_processes
in c:\pywps\pywps_processes\default.cfg
) and find out whether you can get them to run. First test the GetCapabilities request:
<wps:Capabilities service= "WPS" version= "1.0.0" xml:lang= "en-CA" xsi:schemaLocation= "http:/opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsGetCapabilities_response.xsd" updateSequence= "1" > ... </wps:Capabilities> |
and then executing any of the available processes
e.g. http://localhost/cgi-bin/pywps.cgi?service=wps&request=Execute&Identifier=dummyprocess&DataInputs=\[input1=42\]&version=1.0.0.
Step 6 Add wps processes
Now add your own Python processes as WPS by copying your processes to the c:\pywps\pywps_processes
folder too. Use the WPS syntax (Setting up a WPS process using PyWPS) for your python functions as in the copied examples. Change 3 things when adding a new WPS process based on these examples:
- add new file
XYZ.py
toc:/pywps/pywps_processes
- change
identifier
insideXYZ.py
- add
"XYZ.py"
to the list inc:/pywps/pywps_processes/_
init
_.py