Solution for ImportError: No module named web

Once I needed to disable the Nginx web server on the same server with iRedmail and install Apache2. And when I tried to start iRedadmin, it did not open, and in the Apache2 logs I saw:

mod_wsgi (pid=233705): Failed to exec Python script file '/opt/www/iredadmin/'.
mod_wsgi (pid=233705): Exception occurred processing WSGI script '/opt/www/iredadmin/'.
Traceback (most recent call last):
File "/opt/www/iredadmin/", line 8, in <module>
from libs import iredbase
File "/opt/www/iredadmin/libs/", line 5, in <module>
import web
ImportError: No module named web

I tried installing the web framework for Python:

pip3 install
pip3 install

But it turned out that it was already installed:

Requirement already satisfied: in /usr/local/lib/python3.8/dist-packages (0.62)
Requirement already satisfied: cheroot in /usr/local/lib/python3.8/dist-packages (from (8.5.2)
Requirement already satisfied: jaraco.functools in /usr/local/lib/python3.8/dist-packages (from cheroot-> (3.1.0)
Requirement already satisfied: six>=1.11.0 in /usr/lib/python3/dist-packages (from cheroot-> (1.14.0)
Requirement already satisfied: more-itertools>=2.6 in /usr/local/lib/python3.8/dist-packages (from cheroot-> (8.6.0)

I ended up solving the problem by installing libapache2-mod-wsgi-py3:

sudo apt install libapache2-mod-wsgi-py3

After that, the error disappeared.

Example configuration for iredadmin just in case:

WSGISocketPrefix /var/run/wsgi
WSGIDaemonProcess iredadmin user=iredadmin threads=15
WSGIProcessGroup iredadmin

AddType text/html .py

<Directory /opt/www/iredadmin/>
    <IfVersion < 2.4>
        Order deny,allow
        Allow from all
    <IfVersion >= 2.4>
        Require all granted

Alias /iredadmin/static "/opt/www/iredadmin/static/"
WSGIScriptAlias /iredadmin "/opt/www/iredadmin/"

See also my articles:
Installing and Configuring the Apache2 Web Server
Installing and configuring iRedMail
Install and configure Nginx

Leave a comment

Leave a Reply