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.

1 Answer 1

2

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)

3
  • 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? Commented Dec 19, 2021 at 22:11
  • I'm also receiving Invalid command 'WSGIPythonHome' when I check for apachectl -S Commented May 16, 2022 at 6: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 Commented May 16, 2022 at 6:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.