6

I originally had Python 3.6 installed and working well with WSGI and Apache2 on my Linux server.

Then I created a Flask app that had a dependency needing Python 3.7. I've successfully (and I think) upgraded to Python 3.9. Running

python3 or sudo python3

both take me to Python 3.9. But then when I run

sudo apt-get install libapache2-mod-wsgi-py3
The following additional packages will be installed: python3, python3.6

it installs Python 3.6

After this, python3 still points to Python 3.9. However, when the WSGI app is run, Python 3.6 is used, and it breaks. I have installed the Python package mod-wsgi with the correct PIP.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
ThatCoolCoder
  • 193
  • 1
  • 7

1 Answers1

1

You should be able to control which pytho is used via a simple configuration line. E.g. /etc/httpd/conf.d/your_app.conf with

WSGIPythonHome /opt/your_python_env

(I would advise to also set up an venv dedicated to your app if you aren't already doing so)

  • But the mod_wsgi doc said the version of python you are pointing via the above setting, should match the version which mod_wsgi is compiled against. So that should not work for chaning the python major/minor version. Am I right? – Saleh Dec 19 '21 at 22:11
  • I'm also receiving `Invalid command 'WSGIPythonHome'` when I check for `apachectl -S` – Ricky Levi May 16 '22 at 06:28
  • @Saleh then in that case, how the command line gives python3.9 but Apache is using python3.8 - how can it be upgraded then (for Apache) because this affects the `pip install` pkgs, for testing i'm installing with `3.9` but for Apache I need to install it again for `3.8` ?! ... something doesn't make any sense. ( the 3.9 was installed with homebrew, while the system-wide python is in `/usr/bin` – Ricky Levi May 16 '22 at 06:30