How to Install Python on Debian 12

December 26, 2023 / Web Development

Python is a powerful and user-friendly programming language, suitable for both beginners and experienced developers. In this guide, we will explain how to install Python on Debian 12, covering default repositories and external PPAs for previous versions.

  1. Install the latest Python versions from the default Debian 12 repositories by following these steps-

    1. Update the Packages List
      Ensure your system’s package list is up-to-date. Open the terminal and type:

      $ sudo apt update

      This command updates your local software repository index.

    1. Now, Check the Python Version Available
      Before installing Python, check the available version in the repositories. Use the ‘apt’ tool with the ‘show’ option and ‘python3’ as the package name.

      $ apt show python3
    2. Now, Install Python
      Once you’ve verified the Python version, you can install Python by following the command:

      $ sudo apt install python3

      Your system will prompt for your password and initiate the installation process.

    3. Verify the installation
      After completing the installation, confirm it by checking the Python version:

      $ python3 --version

      Running this command should show the Python version you recently installed.

  2.  Install additional Python versions from an external PPA.
    Installing older Python versions on Debian can be challenging as they aren’t in the default repositories. Yet, you can use the Deadsnakes PPA, which offers more Python versions. Here’s how:

    1. Now, Install Required Software
      You need to install the ‘software-properties-common’ package which provides the ‘add-apt-repository’ command. Run:

      $ sudo apt install software-properties-common
    2. Now, Add Deadsnakes PPA
      Add the Deadsnakes PPA to your system’s software sources:

      $ sudo add-apt-repository ppa:deadsnakes/ppa

      Press [ENTER] to proceed or ctrl-c to cancel the addition when prompted.

    3. Now, Update the Packages List
      After you add the PPA, update your package list:

      $ sudo apt update
    4. Install the Python Version
      To install Python 3.8, for example, you’d run:

      $ sudo apt install python3.8

      If your desired version is different, replace ‘3.8’ with the appropriate version number.

    5. Confirm the Installation Process
      Confirm the Python installation by checking its version:

      $ python3.8 --version

    If your version is different, change ‘3.8’ to match your installed version number. For  Information, you can visit our knowledge base section.

Dominos Search