How to install Python 3.11 on Ubuntu 20.04 / Debian 11

The current last stable version available by link https://www.python.org/downloads/release/python-3112/.

Download Python 3.11.2 source

Download and extract the Python source code.

cd /tmp/
wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz
tar -xzvf Python-3.11.2.tgz
cd Python-3.11.2/

Install the build tools

Now, install the build tools. The build tools includes gcc, make, zlib, ssl libraries and other libraries

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev

Configure, make and make install

./configure --enable-optimizations

Now run make. You can make the build using nproc, which returns the number of CPUs.

Make install

The default Python installation is /usr/bin. If you want to install Python under /usr/local/bin instead of overwriting the default, do this:

sudo make altinstall

This will install Python at /usr/local/bin/python3.11. To test the version, run this:

python -V

You will get this output:

Python 3.11.2

Make Python 3.11.2 the default version

For this we can use update-alternatives

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.11 2 
sudo update-alternatives --config python 

Пожалуйста, оцените материал

How to install Python 3.11 on Ubuntu 20.04 / Debian 11
Пролистать наверх