Installation
Ubuntu 20.04
pip3 install pywps
Ubuntu 16.04
Clone the latest PyWPS repository:
git clone https://github.com/geopython/pywps/
Install required packages:
sudo apt-get install git python3-gdal
sudo pip install -e git+https://github.com/geopython/pywps.git@pywps-4.4#egg=pywps
Configuration
Apache WSGI:
sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
Create WPS Directory /usr/local/pywps
and create pywps.wsgi
:
#!/usr/bin/env python3
from pywps.app.Service import Service
# processes need to be installed in PYTHON_PATH
from processes.sleep import Sleep
from processes.ultimate_question import UltimateQuestion
from processes.centroids import Centroids
from processes.sayhello import SayHello
from processes.feature_count import FeatureCount
from processes.buffer import Buffer
from processes.area import Area
processes = [
FeatureCount(),
SayHello(),
Centroids(),
UltimateQuestion(),
Sleep(),
Buffer(),
Area()
]
# Service accepts two parameters:
# 1 - list of process instances
# 2 - list of configuration files
application = Service(
processes,
['/usr/local/pywps/pywps.cfg']
)
Create pypws.cfg
.
*Reference Configuration https://pywps.readthedocs.io/en/master/configuration.html
Create processes
directory and logs
direcoty:
mkdir processes
mkdir logs
chmod 777 logs
touch logs/pywps.log
chmod 777 logs/pywps.log
Create a configuration file /etc/apache2/sites-enabled/pywps.conf
:
# PyWPS
WSGIDaemonProcess pywps python-path=/usr/local/pywps:/usr/local/anaconda3/envs/pywps/lib/python3.6/site-packages/ home=/usr/local/pywps user=www-data group=www-data processes=2 threads=5
WSGIScriptAlias /pywps /usr/local/pywps/pywps.wsgi process-group=pywps
<Directory /usr/local/pywps/>
WSGIScriptReloading On
WSGIProcessGroup pywps
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
Test: http://localhost/wps?request=GetCapabilities&service=WPS
Q&A
[Wed Mar 17 11:35:24.851659 2021] [wsgi:error] [pid 79590:tid 139628017260288] [remote 10.28.140.89:50116] mod_wsgi (pid=79590): Failed to exec Python script file '/usr/local/pywps/pywps.wsgi'.
[Wed Mar 17 11:35:24.851713 2021] [wsgi:error] [pid 79590:tid 139628017260288] [remote 10.28.140.89:50116] mod_wsgi (pid=79590): Exception occurred processing WSGI script '/usr/local/pywps/pywps.wsgi'.
[Wed Mar 17 11:35:24.851782 2021] [wsgi:error] [pid 79590:tid 139628017260288] [remote 10.28.140.89:50116] Traceback (most recent call last):
[Wed Mar 17 11:35:24.851827 2021] [wsgi:error] [pid 79590:tid 139628017260288] [remote 10.28.140.89:50116] File "/usr/local/pywps/pywps.wsgi", line 3, in <module>
[Wed Mar 17 11:35:24.851896 2021] [wsgi:error] [pid 79590:tid 139628017260288] [remote 10.28.140.89:50116] from pywps.app.Service import Service
[Wed Mar 17 11:35:24.851942 2021] [wsgi:error] [pid 79590:tid 139628017260288] [remote 10.28.140.89:50116] ImportError: No module named pywps.app.Service
apt-get install libxml2-dev libxslt-dev
pip install lxml==4.2.5
Reference
https://github.com/geopython/pywps/
https://pywps.readthedocs.io/en/master/deployment.html
python报错ImportError: cannot import name ‘etree’ from ‘lxml’ (E:\python\python\lib\site-packages\lxml
Python爬虫——使用lxml库中的etree模块时显红报错,但又可以正常运行