Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change mod_wsgi from python3.5 to 3.6

I have a flask app that used to run with python3.5 on apache2. I am now trying to change it to run on 3.6 (i have sone type hinting in my code that is only supported on 3.6).

I have installed the module for python3.6, but when tried to restart apache and run my app, it fails.
When running

mod_wsgi-express module-location

I have the python3.5 version

/usr/local/lib/python3.5/dist-packages/mod_wsgi/server/mod_wsgi-py35.cpython-35m-x86_64-linux-gnu.so

The same file also existis on my server in python3.6 dir.
I also changed my $PATH to run python3.6 as a default for python.
How can I tell apache to run on python3.6 and not on 3.5?

like image 402
Nitzan Cohen Avatar asked Mar 04 '18 15:03

Nitzan Cohen


3 Answers

WOHA! It's working!
I uninstalled the mod_wsgi (sudo apt get remove libapache2-mod-wsgi). Then, Installed the module via pip specifically to python3.6 (python3.6 -m pip install mod_wsgi), but at this point the apache still ran python3.5.
I added to the apache configuration file (in ubunutu 16.4 the file is located at: /etc/apache2/apache2.conf and /usr/local/lib64/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so for RHEL/CentOS 7) the followings:
LoadModule wsgi_module "/usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
and
WSGIPythonHome "/usr" and that did the trick.
I weeped a lot of tears over this issue, finding the apache2.conf file etc, so hopefully this will be helpful to anyone.

like image 129
Nitzan Cohen Avatar answered Nov 19 '22 23:11

Nitzan Cohen


The LoadModule solution worked for me. However, I found it easiest to first ensure a2dismod wsgi as provided by the default apache2 module. I spent 3 days looking at various solutions and answers and reviewing Graham's WSGI guide.

like image 5
Marc Ubaldino Avatar answered Nov 19 '22 23:11

Marc Ubaldino


What I did in my case is was to remove python 3.6 from Django env and re-install python 3.5 and it worked.

like image 1
Ian Nato Avatar answered Nov 19 '22 23:11

Ian Nato