Python3 is one of the most productive programming language on the planet, its versatility allows to work on system desktop programing to website programming, and much more. It’s ease of syntax, reliability, and it’s flexibility make it are a few of the many reasons its the goto to getting things done.
Python3 is at version 3.13. Most linux distros are at this time are using the 3.12 and that’s ok, nothing wrong with tested reliability of versions.
Though if the latest version is something that would like to be installed.
I found that if the latest wsgi version is installed, then the latest version of Python3.13 at this time is available to Apache2.
It seems the cgi module utilizes the wsgi module for the latest version of Python3 used by Apache2.
1)
So install the Apache2 cgi module.
sudo apt-get install libapache2-mod-cgi
2)
Next, review the Apache2 modules in use:
sudo apache2ctl -t -D DUMP_MODULES
There should be the cgi and wsgi modules installed.
3)
Next, install the source code for Python3.13, Apache2, and Postgresql.
sudo apt-get install python3.13-dev
sudo apt install apache2-dev
sudo apt install libpq-dev
sudo apt install python3-pip
4)
Finally run the pip
For the latest version to get Python 3.13 working with Apache2.
sudo python3 -m pip install –target /home/FOLDER/.local/lib/python3.13/site-packages mod_wsgi
Otherwise, it’s
sudo apt-get install libapache2-mod-wsgi-py3
5)
Optional
Postgresql linux Python3 driver.
from source
sudo python3 -m pip install psycopg2
or it’s binary
sudo apt-get install psycopg2-binary
6) To change versions of Python3 is easy, for example, from Python3.12 to Python3.13
First, create two entries of each version of Python3 so the update-alternatives program can locate them.
sudo update-alternatives –install /usr/bin/python3 python3 /usr/bin/python3.12 1
sudo update-alternatives –install /usr/bin/python3 python3 /usr/bin/python3.13 2
Then changing between the two versions with the following statement.
sudo update-alternatives –config python3
Happy coding!
BTW: Pythons are not poisonous. And FWI Python3 programming language is named after Monty Python, the comedy movie.