Cannot make Python 3.10 virtual environment work with mod_wsgi / Apache webserver

Viewed 315

I'm trying to set up a Flask webserver. I'm trying to use virtual environment with Python 3.10. I've been at it for hours, and probably have tried every suggested solution from SO, but they all don't seem to work for me https://flask.palletsprojects.com/en/2.0.x/deploying/mod_wsgi/#working-with-virtual-environments. It just keeps defaulting to the system Python version. Is it even compatible with Python3.10 yet? With the system Python 3.8 (Ubuntu 20) venv it works completely fine for some reason...

.wsgi file:

#!/var/www/html/myApp/env/bin/python3

activate_this = '/var/www/html/myApp/env/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))

import sys
print(sys.version)

sys.path.insert(0, "/var/www/html/myApp/")

from flask_app import app as application   

       

enter image description here

Apache:

<VirtualHost *:80>
WSGIDaemonProcess myApp python-home=/var/www/html/myApp/env/
WSGIScriptAlias / /var/www/html/confgen-webapp/myApp.wsgi
    <Directory /var/www/html/myApp>
        WSGIProcessGroup myApp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
0 Answers
Related