Installing Python3.12 from source
To use the latest version of Python, compile it from source in your home folder.
◆◆ Beware! ◆◆ This IS NOT supported. It may stop working at any time or not work at all. Do not use in PRODUCTION. Experts Only.
Compiling Python 3.12
Those that have read my other articles know that I compile everything in the folder ~/sourcecache
. Make that folder now if you are following along.
Commands
Obtain the source from python.org. ./configure
, make
, and make install
.
cd ~/sourcecache && wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tgz && tar -xzvf Python-3.12.4.tgz && cd Python-3.12.4
./configure --prefix=$HOME/.local --with-openssl=/usr/ --enable-optimizations && make && make install
If all goes well, after a long while of running, you should see:
...
Installing collected packages: pip
Successfully installed pip-24.0
Try It
Try out the python3.12 command.
% python3.12 --version
Python 3.12.4
% python3.12 -m pip --version
pip 24.0 from /home/jason/.local/lib/python3.12/site-packages/pip (python 3.12)
Success! I have the latest python and PIP is already installed!
Let's try making a virtual environment.
% python3.12 -m venv ~/projects/venv-3.12-test
% cd ~/projects/venv-3.12-test/
% source bin/activate
(venv-3.12-test) % which python
/home/jason/projects/venv-3.12-test/bin/python
It works!
Important Note!
Python was compiled without some of its optional modules. You may have noticed the following output while Python was compiling.
The necessary bits to build these optional modules were not found:
_bz2 _ctypes _ctypes_test
_dbm _gdbm _lzma
_tkinter readline
To use any of those modules you will need to obtain the devel version of the lib and recompile Python.