Module not found error when running script as wsgi within Apache

350 Views Asked by At

I have a developed Server application using pywps on a Flask server and now im trying to migrate it to an apache server.

Tech-stack : OS: Windows Server Python 3.9.6 Apache 2.4.48 (Win64) mod-wsgi 4.8.0

I can open the configured URL but receive a status code 500. Error log says the following:

mod_wsgi (pid=7212, process='', application='127.0.0.1:8008|/wps'): Loading Python script file 'C:/Apache24/wps_env/pywps-flask-master/pywps.wsgi'.
mod_wsgi (pid=7212): Failed to exec Python script file 'C:/Apache24/wps_env/pywps-flask-master/pywps.wsgi'.
mod_wsgi (pid=7212): Exception occurred processing WSGI script 'C:/Apache24/wps_env/pywps-flask-master/pywps.wsgi'.
Traceback (most recent call last):\r
File "C:/Apache24/wps_env/pywps-flask-master/pywps.wsgi", line 9, in <module>\r
 import pywps\r
ModuleNotFoundError: No module named 'pywps'\r

The wsgi file in question is :

from pathlib import Path
import pywps
from pywps import Service

from processes.sayhello import SayHello
from processes.csv_input import CSVInputs 

processes = [
    SayHello(),
    CSVInputs()
]
application = Service(processes, [Path(r'C:\Users\Jdoe\wps_env\pywps-flask-master\pywps.cfg')])

Now comes the strange thing, i am able to execute this exakt same script from the powershell with no errors at all. I would rule out, path or enviroment related issues, because i have installed all pip packages which i used in the virtaul enviroemnt i have to develop in the global namespace aswell, so both interpreters know the same packages. I know this is not best practice, but i'm currently working in a sandbox anyway and this more a POC then anything else.

Since the wsgi application tries to run, i also assume that my apache conf is correct.

What am I missing here?

Thank you for your help

1

There are 1 best solutions below

1
On

ModuleNotFoundError means that a module is missing and that you have to install it. In your case its PyWPS. So open a terminal and type

pip install pywps

or

pip3 install pywps

then if you rerun your code it should work.

P.S. You can find the package on PyPI