ImportError: No module named site

Skip to first unread message

Jan 25, 2021, 12:16:29 PMJan 25
to modwsgi
Hello All,

I am setting up a new web server using the following:
(venv) [dev_user@96f98ccbad74 ~]$ pip freeze

(venv) [dev_user@96f98ccbad74 ~]$ python --version
Python 3.6.8

(venv) [dev_user@96f98ccbad74 ~]$ httpd -v
Server version: Apache/2.4.6 (CentOS)

I used the following command to place the mod_wsgi module from 4.7.1 into the modules directory in the apache directory:
mod_wsgi-express install-module  

Which resulted in this output:
LoadModule wsgi_module "/home/dev_user/venv/lib64/python3.6/site-packages/mod_wsgi/server/"
WSGIPythonHome "/home/dev_user/venv"

I removed the "" and placed those two lines in my httpd.conf file with some other lines as well:
LoadModule wsgi_module modules/

WSGIScriptAlias / /home/dev_user/integra/integra/
WSGIPythonHome /home/dev_user/venv
WSGIPythonPath /home/dev_user/integra

#IncludeOptional conf.d/*.conf

<Directory /home/dev_user/integra/integra>
Require all granted

Directory structure
(venv) [dev_user@96f98ccbad74 home]$ ls dev_user
integra  venv
(venv) [dev_user@96f98ccbad74 home]$ ls dev_user/integra
core  integra
(venv) [dev_user@96f98ccbad74 home]$ ls dev_user/integra/integra

I'm not sure what I am missing but I cannot reach my site and the error in the log file is:
[Mon Jan 25 17:25:07.931962 2021] [:info] [pid 50384] mod_wsgi (pid=50384): Python home /home/dev_user/venv.
[Mon Jan 25 17:25:07.931997 2021] [:info] [pid 50384] mod_wsgi (pid=50384): Initializing Python.
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site

Thank you for the help in advance!

Graham Dumpleton

Jan 25, 2021, 2:29:45 PMJan 25
If your Apache config file still has:

    LoadModule wsgi_module modules/

in it, then you likely still have the system package for mod_wsgi installed.

You can't use both at the same time and if it is for a different Python version than your virtual environment it can fail in the way shown.

You can also have it fail as you see when the Apache user cannot access inside your home directory because of filesystem permissions of SELinux.

It is better to not have the virtual environment and project code under your home directory, but under /var/www or other location that Apache does have access to.


You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Jan 25, 2021, 3:47:14 PMJan 25
to modwsgi
As usual you are right Graham removed the old mod_wsgi from the httpd directories and moved my project to var/www.  My welcome page is up.  Thank you!
Reply all
Reply to author
0 new messages