Apache2 ImportError: No module named site

Posted October 5, 2021 100 views
ApachePythonDjangoPython FrameworksUbuntu 20.04

Hi, I recently rented a Linux server with ubuntu 20.04 and made a free domain for deploy my web app but unfortunately, I can’t get over this problem.
I already follow your tutorial and it works perfectly on my RaspberryPi4 and was able to deploy the web app without any big issue.
So now I’m trying to do the same on an external server but without success.

This is the error.log from Apache2:

[Tue Oct 05 11:46:23.604549 2021] [wsgi:warn] [pid 436982:tid 139990313458752] (2)No such file or directory: mod_wsgi (pid=436982): Unable to stat Python home /home/davide/windweather/windenv. Python interpreter may not be able to be in Verify the supplied path and access permissions for the whole of the path>
ImportError: No module named site

I verified first the WSGI file in Apache and all the paths for python virtual env seem correct and the python home also. I checked if the python version and the python version when the mod_wsgi was compiled are the same: 3.8.

I copy also my WSGI for double check maybe I miss something.

Alias /static /home/davide/WindWeather/static
    <Directory /home/davide/WindWeather/static>
        Require all granted

    <Directory /home/davide/WindWeather/WindWeather>
            Require all granted

    WSGIDaemonProcess WindWeather python-home=/home/davide/windweather/windenv python-path=/home/davide/WindWeather
    WSGIProcessGroup WindWeather
    WSGIScriptAlias / /home/davide/WindWeather/WindWeather/

Thank you for any help and I hope someone can tell me at least where I have to check to resolve this problem. Let me know if you need more info


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

When you initially installed Apache, did you also install the libapache2-mod-wsgi module?

You can do that with the following commands:

sudo apt-get update
sudo apt-get install libapache2-mod-wsgi

To check if the module is enabled run:

apachectl -M

You might have to restart Apache as well.

Let me know how it goes.

  • Hi,

    Bobby thank you for your replay. I checked like you says and everything was in order. I checked then in which version of python was compiled the mod_WSGI and I found out to have two versions of python. So I delete everything reinstall the mod_WSGI.

    Thank for the help



    edited by bobbyiliev