Apache2 ImportError: No module named site

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


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted 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. Best, Bobby