HomeDEBIANInstall Python 3.11 on Debian 11

Install Python 3.11 on Debian 11

Welcome to our today’s guide on how to Install Python 3.11 on Debian 11. Python is a popular programming language that is user-friendly and simple to learn. It is most commonly used in machine learning, artificial intelligence, big data, graphical user interface (GUI)-based desktop applications, and robotics. It’s also useful for frontend and backend development, web robotization, computer vision, and code testing.
Furthermore, it is compatible with various programming languages such as C, Java, and C++. Python’s advantage when debugging is that it executes code line by line, making it easy to discover errors. It’s also platform-agnostic, which means you can write code once and run it anywhere.

Python 3.11, which was released on October 24, 2022, comes with a range of fascinating improvements that developers can explore and experiment with. These improvements include:

  • Structural Pattern Matching: this makes it more capable and efficient, as well as better Type Hinting that is now easier to use and extend
  • Improved error messages: providing more informative and actionable diagnostics for developers.
  • Improved AsyncIO: the Python library for asynchronous I/O programming, has been improved in Python 3.11 to make it more efficient and easier to use.
  • Enhanced Security: Python 3.11 has improved security by supporting the OpenSSL 3.0 library, which provides better security and performance.
  • New modules: Python 3.11 includes several new modules, including graphlib for working with graphs and jankson for parsing JSON.
  • Better Type Hinting: Python 3.11 makes it easier to use and extend the type hinting system.

Install Python 3.11 on Debian 11

In our previous guides, we covered how to install Python 3.11 on:

Use the below steps to install Python 3.11 on Debian 11

Step 1: Update the system

Use the command below to update your system to the most recent packages.

sudo apt update && apt upgrade -y
sudo reboot

Install the necessary prerequisites so that Python may be installed from the source code.

sudo apt install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev -y

wget can be used to download Python 3.11, or you can do so by visiting the Downloads page.

wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz

Use the following command to extract the downloaded tarball:

tar -xvf Python-3.11.1.tar.xz

Start the compilations by switching to the extracted directory.

cd Python-3.11.1
 ./configure --enable-optimizations

Sample output:

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for Python interpreter freezing... ./_bootstrap_python
checking for python3.11... no
checking for python3.10... no
checking for python3.9... python3.9
checking Python for regen version... Python 3.9.2
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
.............
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/Setup.bootstrap
config.status: creating Modules/Setup.stdlib
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
configure: creating Modules/Setup.local
configure: creating Makefile

Then use the command below to create and install Python.

sudo make altinstall

Be patient, it takes a while to complete.

Step 2: Create a default environment for Python 3.11

The following command will create a symbolic link to Python3 if you have an older version of Python3 and want to make Python 3.11 the default.

sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 1

Now check the version.

$ python3 --version
Python 3.11.1

Step 3: Install modules for Python on Debian 11

Python Package Manager can be used to install Python Modules (PIP). If PIP isn’t already installed, run the following command to install it.

sudo apt install python3-pip

In order to verify a successful installation, check the pip version.

$ pip3 --version
pip 22.3.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)

Now utilize the following command syntax to install the modules.

python3 -m pip install <ModuleName>

Use the command syntax below to install a package that is isolated to a certain user.

python3 -m pip install --user <ModuleName>

Let’s attempt the <Flask module> installation.

python3 -m pip install flask

Then use the following command to verify the module’s specifics.

python3 -m pip show flask

The following command should be used to upgrade a module.

$ python3 -m pip install --upgrade flask
Name: Flask
Version: 2.2.3
Summary: A simple framework for building complex web applications.
Home-page: https://palletsprojects.com/p/flask
Author: Armin Ronacher
Author-email: [email protected]
License: BSD-3-Clause
Location: /home/ezrah/.local/lib/python3.11/site-packages
Requires: click, itsdangerous, Jinja2, Werkzeug
Required-by: 

To remove a module:

$ python3 -m pip uninstall flask
Found existing installation: Flask 2.2.3
Uninstalling Flask-2.2.3:
  Would remove:
    /home/ezrah/.local/bin/flask
    /home/ezrah/.local/lib/python3.11/site-packages/Flask-2.2.3.dist-info/*
    /home/ezrah/.local/lib/python3.11/site-packages/flask/*
Proceed (Y/n)? y
  Successfully uninstalled Flask-2.2.3

Step 4: A demo Python program running on Debian 11

Use the following command to launch the Python interpreter.

$ python3.11
Python 3.11.1 (main, Feb 16 2023, 09:03:18) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

The output of the statement is produced by entering the following code and pressing Enter.

>>> print("Hello, My fellow Pythonistas!")
Hello, My fellow Pythonistas!

Python can be used as a calculator as well. To obtain a value, try performing the following expressions.

>>> 4+4
8
>>> 7*7
49
>>> 10+10
20

Final Thoughts

This is the end of our guide on How To Install Python 3.11 on Debian 11.

Python is an open-source programming language that enables quicker work and more efficient system integration. It is the perfect language for scripting and quick application development in many domains on most platforms because of its elegant syntax and dynamic typing.

Read more about Python 3.11.

Other cool guides:

- Advertisment -

Recent posts

LEAVE A REPLY

Please enter your comment!
Please enter your name here