How to Install Python and Pip on Debian 12?
What is Python?
Python is a high-level programming language that is interpreted and known for its simplicity, readability, and multi-functionality. It is very widely used for web development, automation, data science, artificial intelligence, and much more. Backed by a strong community and an exhaustive set of libraries, Python is one of those languages that gets favored among beginners and professionals alike.
What is Pip?
Pip (Pip Installs Packages) is a package manager for Python. It is used to install, upgrade, and manage thousands of open-source Python packages and their dependencies from the Python Package Index (PyPI).
Why Install Python and Pip on Debian 12?
Debian 12 is a stable and secure distribution of Linux that is very popular with system administrators and developers. Installing Python and Pip on Debian 12 allows you to:
- Edit and run your Python programs.
- Install any third-party Python modules that you need for development and automation.
- Use Python for scripting or system administration Machine learning, data science, or AI libraries available in Python.
- Such high-level computing development involves, for a web-based application, a framework such as Django or Flask.
In this guide, we will illustrate how to install both step by step.
Steps to Install Python and Pip on Debian 12
Step 1: System Updations
Before installing Python and Pip, updating the system packages is crucial. Use the following command to update your system!
sudo apt update && sudo apt upgrade -y
This updates your system with the latest security patches and software updates.
Step 2: Ensure that Python is Preinstalled
Debian 12 comes with Python pre-installed. To check what version of Python is installed, use:
python3 --version
In case it is installed, you will see something like:
Python 3.x.x
If Python is not installed or you need a newer version, go on to the next step.
Step 3: Python Installation
To install Python 3, you need to run the command below:
sudo apt install python3 -y
Once the installation is finished, verify it:
python3 --version.
Step 4: Installation of Pip in Python 3
Pip is a package manager for installing and managing Python packages. To install Pip, run
sudo apt install python3-pip -y
Now check that the installation was successful by checking the version:
pip3 --version
It should return output similar to:
pip 22.x.x from /usr/lib/python3/dist-packages/pip (python 3.x)
Step 5: Verify Python and Pip Installation
You can confirm both Python and Pip installations were done correctly by running
python3 --version pip3 --version
Once these two commands return the expected versions, the setup is complete.
Step 6: Install Basic Development Tools(Optionable).
If you plan to build Python packages from their source codes, you need to install more dependencies:
sudo apt install build-essential libssl-dev libffi-dev python3-dev -y
Conclusion
Now, you have installed Python and Pip on Debian 12! You are now ready to code, install libraries, and work on Python projects. Keep your Python environment updated and consider using virtual environments for using different dependencies.
Frequently Asked Questions
What command can I execute to check the installed Python version on Debian 12?
To check the Python version on Debian 12, run the following command:
python3 --version
Can I have multiple Python versions on Debian 12?
Yes, you are able to install multiple versions of Python using such tools as pyenv or do so manually by compiling a different version.
How can I upgrade Pip on Debian 12?
Pip can be updated on Debian 12 using the command:
pip3 install --upgrade pip
How to uninstall Python from Debian 12?
To remove Python 3 from Debian 12, use the command:
sudo apt remove python3 -y
Be careful, as some of the system utilities might depend on Python.
What is the difference between Pip and Pip3?
Pip is for Python 2 (which became deprecated), while pip3 is for Python 3. Since Python 2 is obsolete now, use pip3 at all times.