pywps-flask icon indicating copy to clipboard operation
pywps-flask copied to clipboard

ModuleNotFoundError: No module named 'pywps.wpsserver'

Open benjimin opened this issue 4 years ago • 8 comments

There seems to be an incompatibility between the latest versions of pywps (4.5.0) and pywps-flask (master branch as of today).

$ git clone https://github.com/geopython/pywps-flask.git .

$ python demo.py
Traceback (most recent call last):
  File "demo.py", line 36, in <module>
    from processes.area import Area
  File "/home/jovyan/wps/pywps-flask/processes/area.py", line 6, in <module>
    from pywps.wpsserver import temp_dir
ModuleNotFoundError: No module named 'pywps.wpsserver'

$ python
Python 3.6.9
>>> import pywps
>>> pywps.__version__
'4.5.0'

For what it's worth, I also tried using an earlier version of pywps, but that led to other dependency version conflicts.

$ pip install pywps flask
Requirement already satisfied: pywps in /env/lib/python3.6/site-packages (4.2.4)
Requirement already satisfied: flask in /env/lib/python3.6/site-packages (2.0.0)
Requirement already satisfied: werkzeug in /env/lib/python3.6/site-packages (from pywps) (2.0.1)

$ python -c "import pywps"
Traceback (most recent call last):
  File "/env/lib/python3.6/site-packages/pywps/exceptions.py", line 17, in <module>
    from werkzeug._compat import text_type
ModuleNotFoundError: No module named 'werkzeug._compat'

benjimin avatar Sep 02 '21 06:09 benjimin

I was facing the same issue. Have found a local workaround with the following versions. However, now I am not sure if the tested stuff will work with the newest PyWPS; a general solution would be appreciated.

pip install flask==1.1.4 werkzeug==1.0.1 pywps==4.2.11

pesekon2 avatar Oct 02 '21 10:10 pesekon2

I am also facing the same issue!

iamtekson avatar Oct 12 '21 02:10 iamtekson

Same here.

rtaib avatar Apr 26 '22 04:04 rtaib

Still valid issue. What is the reason of python-flask to be broken for so long time?

landam avatar Aug 29 '22 07:08 landam

Update:

pip install flask==1.1.4 werkzeug==1.0.1 pywps==4.2.11 MarkupSafe==2.0.1

landam avatar Aug 29 '22 07:08 landam

Also got the same problem:

pywps: 4.5.2 flask: 2.2.2 python:3.10.6

I removed Area from the demo project under the import and Processes. Than the demo would start!

sehHeiden avatar Dec 05 '22 21:12 sehHeiden

FYI, for anyone still encountering the issue:

If you just want to use PyWPS with Flask, you do not need this repo (which is apparently just a demo, and seems defunct and overcomplicated anyway). Instead follow the standard instructions for PyWPS (perhaps in combination with the Flask instructions for WSGI apps).

A fairly minimal example goes roughly like this:

import flask
import pywps

class dummy(pywps.Process):
    def __init__(self):
        super().__init__(handler=self._handler,
                         identifier='dummyproc',
                         title='Dummy Process',
                         inputs=[pywps.LiteralInput('input', "Some input", data_type='string')],
                         outputs=[pywps.LiteralOutput('response', "Some output", data_type='string')])
    def _handler(self, req, resp):
        resp.outputs['response'].data = req.inputs['input'][0].data + " and foo"

service = pywps.Service([dummy()])
app = flask.Flask(__name__)
app.route('/wps', methods=['GET', 'POST'])(lambda: service)
app.run()

Then, in a separate process, you can test it with something like:

import owslib.wps
client = owslib.wps.WebProcessingService('http://127.0.0.1:5000/wps')
client.getcapabilities()
print(client.processes)

For real applications you would use one of the pywps geometry input types.

benjimin avatar Dec 07 '22 23:12 benjimin

FYI, for anyone still encountering the issue:

If you just want to use PyWPS with Flask, you do not need this repo (which is apparently just a demo, and seems defunct and overcomplicated anyway). Instead follow the standard instructions for PyWPS (perhaps in combination with the Flask instructions for WSGI apps).

A fairly minimal example goes roughly like this:

... For real applications you would use one of the pywps geometry input types.

For testing, if you have QGIS, you can install the WPS Client (enable experimental plugins first).

aleksandaratanasov avatar Apr 05 '23 13:04 aleksandaratanasov