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 terminal and also set the default version.

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

Also, Python offers good scalability and can be used for complex software projects. Due to the expressive, minimalist syntax, applications can be implemented with just a few lines of code and less susceptibility to 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 runs on Windows, Linux/Unix, Mac OS X, and more… There are also integrations into the virtual machines of Java and. NET.

The 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 of various programming paradigms
  • good extensibility thanks to a large collection of Python add-on packages
  • good scalability
  • extensive standard library available
  • suitable for complex tasks and almost all application problems
  • usable for the common operating systems
  • freely available

Python 3 or 2 installation on Debian 11 Bullseye Linux

1. Run system update

We should run the system update command before installing any package on the Linux system. This rebuilds the system’s repo cache and helps it to recognize the latest versions of packages available to install.

sudo apt update

 

2. Install Python 3.9 on Debian 11 or 10

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

sudo apt install python3 python3-pip

 

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

In case you also want Python 2 on your Debian then run the given command:

sudo apt install python

To install Python 2.7 pip, use the following ones:

sudo apt install curl
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2 get-pip.py

pip2 --version

 

3. Check installed versions

Once the installation is completed you can check what are the versions installed exactly for Python 3 and 2 using the below given command:

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

 

4. Set Default Python version to 3

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

Check the available python versions on your system:

ls /usr/bin/python*

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

Edit Bash profile:

nano ~/.bash_profile

Add the following line. You can change the version, with some other available one, if you want.

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

Here we are setting 3.9 as the default. 

Now, log out and log in again or simply source the bash file:

source ~/.bash_profile

Finally, check the default version:

python --version

Install Python 3 or 2.7 on Debian 11 Bullseye Linux

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.