geopython / pywps-flask

Demo service for PyWPS 4 with Flask
MIT License
21 stars 31 forks source link

ModuleNotFoundError: No module named 'pywps.wpsserver' #61

Open benjimin opened 3 years ago

benjimin commented 3 years ago

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'
pesekon2 commented 2 years ago

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
iamtekson commented 2 years ago

I am also facing the same issue!

rtaib commented 2 years ago

Same here.

landam commented 2 years ago

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

landam commented 2 years ago

Update:

pip install flask==1.1.4 werkzeug==1.0.1 pywps==4.2.11 MarkupSafe==2.0.1
sehHeiden commented 1 year ago

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!

benjimin commented 1 year ago

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.

aleksandaratanasov commented 1 year ago

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).