Python programming language, which is also known as the language of Data Science, has been used to develop web-based, mobile-based, and desktop-based applications for a very long time.
Fortunately, this language can be installed and used in almost every operating system. The same is the case for Debian 12 bookworm. We can install Python in Debian 12 Bookworm in different ways. This article will only discuss two different ways to do that. So let’s start.
Method 1: Install Python With Package Manager (APT)
In the first method, we will follow the traditional approach. We will install our Python in Debian 12 from the APT package manager.
Update and Upgrade the system
Not only for Python, whenever we want to install a new package or software in our Linux Distribution, we should update it first.
After we are done updating the packages, now we can simply install Python with the following command.
Confirm the installation
To confirm the installation of Python in our Debian 12, we can check its version. It will ensure if the python is installed or not.
Here it shows the version as 3.11.2 which means, Python has been installed successfully. Now let’s move ahead and install Python using the second method.
Method 2: Install Python using pyenv
This is another way and approach for installing Python in Debian 12 by using pyenv, which is a popular Python version management tool. With this method, we can easily install multiple versions of Python.
Before we install pyenv, we need to install some prerequisites for it and it can be done by the following command.
libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git
As we have installed the needed prerequisite for the pyenv, now we can install it without any problem
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
Install Python with pyenv
Now we are ready to install using the pyenv instead of apt or some other package manager.
Check the Python version and confirm installation
Again, we can use the same command as earlier to confirm the python installation.
Python installation in Debian 12 is an easy and straightforward process. In this article, we have seen two different methods: the first one is through the apt and the second one by utilizing the pyenv tool for version management.
You can follow any of these to install Python in your Debian 12 bookworm version and start developing wonderful applications and systems.