Install Python 3.x or 2.7 on Debian 11 Bullseye Linux

Learn the commands to install Python 3.x and Python 2.7 on Debian 11 Bullseye or 10 Buster using a terminal and also set the default version.

Python is a free and open source programming language for a wide variety of software projects. This programming language comes with a clear syntax and good readability. It is considered easy to learn and can be interpreted in popular operating systems.

In addition, Python offers good scalability and can be used for complex software projects. Due to the expressive and minimalist syntax, applications can be implemented with just a few lines of code and less chance of programming errors. To ensure simplicity and clarity, Python gets along with very few keywords and uses indentations as structuring elements.

The platform independent programming language Python works on Windows, Linux / Unix, Mac OS X, and more… There are also integrations in Java and virtual machines. REPORT.

Ee Python programming language offers a number of advantages. The most important advantages are briefly summarized below:

  • simple syntax
  • easy to learn due to the small number of keywords and the clear structure
  • no variable declaration is necessary
  • little prone to errors
  • fewer lines of code compared to many other programming languages
  • easy to read and maintain code
  • Support for various programming paradigms
  • good extensibility thanks to a large collection of complementary Python packages
  • good scalability
  • extensive standard library available
  • suitable for complex tasks and almost any application problem
  • usable for common operating systems
  • available for free

Installing Python 3 or 2 on Debian 11 Bullseye Linux

1. Run the system update

We need to run the system update command before installing any package on the Linux system. This rebuilds the system repository cache and helps it recognize the latest versions of packages available for installation.

sudo apt update

2. Install Python 3.9 on Debian 11 or 10

Although if you are using the Debian 11 or 10 Desktop Full-DVD GUI, Python 3.x will already be present on your system. However, minimum Debian system users can opt for the command given below.

sudo apt install python3 python3-pip

3. To install Python 2.7 & Pip on Debian 11 (optional)

If you also want Python 2 on your Debian, run the given command:

sudo apt install python

To install Python 2.7 pip, use the following:

sudo apt install curl
curl --output

sudo python2

pip2 --version
pip --version

3. Check the installed versions

Once the installation is complete, you can check which versions are installed exactly for Python 3 and 2 using the command below:

python3.9 --version
python2 --version
pip --version

4. Set the default Python version to 3

If you have both Python 3 and 2 installed on your Debian 11 or 10 system, the default version will be set to Python 2, so you can change it to Python 2 if you want.

Check the versions of python available on your system:

ls /usr/bin/python*

To set the desired version as the default, use the commands below:

Edit the Bash profile:

nano ~/.bash_profile

Add the following line. You can change the version, with another available, if you wish.

alias python='/usr/bin/python3.9'

Here we set 3.9 as default.

Now log out and log back in or just source the bash file:

source ~/.bash_profile

Finally, check the default version:

python --version

Remove or uninstall Pip & python 2 or 3 from Debian 11

For version 2: sudo python -m pip uninstall pip

For version 3: sudo apt autoremove python3-pip --purge

To remove python:

sudo apt autoremove python --purge
sudo apt autoremove python3 --purge

About Jon Moses

Check Also

NSA, CISA say: don’t block PowerShell, here’s what to do instead

Image: Getty Images/iStockphoto Cybersecurity authorities in the United States, United Kingdom, and New Zealand have …