How To Install Python and PIP on Debian 12
In this tutorial, we will show you how to install Python and PIP on Debian 12. For those of you who didn’t know, Python, renowned for its readability and ease of use, has become the language of choice for diverse applications, including web development, data analysis, and artificial intelligence. PIP, a package management system for Python, simplifies the installation and management of third-party libraries and frameworks.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you step-by-step install Python and PIP programming language on a Debian 12 (Bookworm).
Prerequisites
- A server running one of the following operating systems: Debian 12 (Bookworm).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Python and PIP.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Python and PIP on Debian 12 Bookworm
Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt
commands in the terminal:
sudo apt update && sudo apt upgrade
This command will refresh the repository, allowing you to install the latest versions of software packages.
Step 2. Installing Python on Debian 12.
To install Python on Debian 12 Bookworm, we recommend utilizing the APT package manager, which simplifies the process and ensures compatibility with the Debian ecosystem:
sudo apt install python3
To ensure a successful installation, it’s crucial to verify the Python version. Execute the following command in the terminal:
python3 --version
This command will display the installed Python version, confirming that the installation was successful.
If you specifically require Python 2 programming language, you can install it by running:
sudo apt install python2
Note that Python 2 is no longer actively maintained and will reach its end of life in 2020. It is recommended to use Python 3 for new projects.
Step 3 Installing PIP on Debian 12 Bookworm:
Once Python is installed, installing PIP allows for seamless management of Python packages. While there are multiple methods available, we recommend the following steps for a smooth installation:
sudo apt install python3-pip
To confirm the successful installation of PIP, execute the following command:
pip3 --version
This command will display the installed PIP version, indicating that the installation was completed successfully.
Step 4. Using PIP to Install Python Packages.
Now that you have Python and PIP installed, you can use PIP to install Python packages. For example, to install the popular NumPy package, you can run:
pip3 install numpy
This command will download and install the NumPy package and its dependencies.
Congratulations! You have successfully installed Python and PIP. Thanks for using this tutorial to install Python and PIP programming language on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Python website.