How to Install Pip3 on Debian 12?


Pip3 is an important tool for system administrators and Python developers. It allows users to download as well as manage Python-based packages through the Python Package Index (PyPI). In addition, install packages, manage package versions, update packages, and more from the PyPI and other sources. Debian 12 ships with Python 3, as Python 2 is deprecated.

Based on its significance, this article will explain all possible ways to install pip3 on Debian 12. As well as run Python script files and many more.

How to Install Pip3 on Debian 12?

Pip3 is a useful tool for dealing with Python packages. To install pip3 on Debian 12, you have a couple of methods. Let’s explore these:

Method 1: Install Pip3 Using the Default Repository

Pip3 allows users to search, download, and install packages from the PyPI and other package indexes. To install Pip3 from the default Debian repository, follow the below steps:

Step 1: Update Packages

Update your package list to ensure everything is up to date:

sudo apt update

Step 2: Install Python3

Since Pip3 is associated with Python3. So, use the “python3-pip” package to install Python3 or pip3 as below:

sudo apt install python3-pip

Step 3: Check Pip3 Installation

To verify that Pip3 has been installed correctly, check its version by typing:

pip3 --version

Optional: Install Other Packages Using Python 3

Remember that Python 2 is no longer supported, so we use Python 3 for all our package management needs. For instance, install panda using Python 3 as below:

sudo apt install python3-pandas

Note: Users can also utilize the “pip3 install <package_name>” syntax for the Installation of other packages.

Uninstall Pip3 on Debian 12

To uninstall Pip3 on Debian 12, use the “python3-pip” package with the “remove” utility. It removes Pip3 and all its dependencies from the Debian system:

sudo apt remove python3-pip # Remove Package Only

sudo apt purge python3-pip # Remove Package as well as Files

sudo apt autoremove python3-pip # Completely Remove (Not Recommended)

You’ll be prompted to confirm the uninstallation.

Note: pip3 is the package installer for Python 3, allowing users to manage Python packages efficiently. Now you’re all set to work with Python packages on Debian 12.

Method 2: Install Pip3 by Downloading the Python Script

Alternatively, you can install Pip using a script specifically designed for Pip installation. If you prefer to download the installation script, obtain the script from the official Python website or other trusted sources. To install Pip3 using the Python script, follow the stated steps:

Step 1: Update Package List

First, update your package list via the “update” utility as below:

sudo apt update

Step 2: Install pip3

Then install pip3 using the “python3-pip” command. In addition, install the “python3-venv” package for the Python environment (optional):

sudo apt install python3-venv python3-pip

Users can also upgrade an existing pip installation with the “upgrade” utility along with the “sudo” privileges as below:

sudo -H pip3 install --upgrade pip

Step 3: Run the Python Script

Now, visit the official pip website and download the “get-pip.py” script or execute the below script:

wget https://bootstrap.pypa.io/get-pip.py

Then, switch to the (specific) directory where users downloaded the script. Finally, run the following command to install pip3:

python3 get-pip.py

In this way, “pip-24.0” is installed on Debian 12.

Fix the “externally-managed-environment” Error

If users find “error: externally-managed-environment”, run the “sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED” command. It removes the duplicated path and remains the original PATH directory.

Step 4: Verify Pip3 Installation

To check if Pip3 is installed on your Debian system, run the “–version” utility as below:

pip3 --version

Optional: Manage Python Packages

If the pip3 command is not found, follow the installation steps above. Now you’re ready to manage Python packages using Pip3:

pip3 install flask

That is all from the installation of pip3 on Debian 12.

How to Install Python on Debian 12?

Python is a dynamic language (programming) that’s utilized for several tasks. To install Python from default repositories, follow the below steps:

Step 1: Update Packages List

First, make sure the package list is upgraded/up-to-date. For this, execute the below script line:

sudo apt update

Step 2: Check Python Version

Before installing any package, it’s a decent practice to check the version availability in the repositories. For instance, use the “python3” as the package name with the “show” utility:

sudo apt show python3

Step 3: Install Python

After confirming the Python version from the above step 2, users can install “python3” by running the below command:

sudo apt install python3

Step 4: Confirm the Installation

Once the installation process is complete, verify the Python installation by checking its version:

python3 --version

Important: By default, Debian 12 contains the Python 3 installation having the “Python 3.11.2” version.

Optional: Remove/Uninstall Python

To uninstall Python along with all its dependencies on Debian 12, execute the following command in your terminal:

sudo apt purge python3*

Note: Keep in mind that various system utilities rely on Python, so it’s generally not recommended to uninstall it unless necessary.

To explore more methods of Python installation on Debian 12, follow our guide.

How to Install a Specific/Particular Version of Python on Debian 12?

Users can use the”sudo apt show python3” command to enlist additional Python versions if available on the repository. Let’s follow the stated instructions:

Install the Specific/Desired Python Version

You can now install your desired Python version. For instance, install Python 3.11, (replace 3.11 with your available version) and run:

sudo apt install python3.11

Users can replace 3.11 with the available version number based on their needs.

Confirm Python

Finally, verify the Python version by using the “version” utility as below:

python3.11 --version

Optional: Uninstall Specific Version of Python

To uninstall specific versions of Python on Debian 12, first, determine which Python versions you want to remove by checking installed Python versions:

whereis python3

This displays the paths associated with different Python versions on your system.

Uninstall Python Versions

To uninstall a specific version of Python, use the “remove” utility by mentioning the version name:

sudo apt remove python3

This is all from the article.

Conclusion

Pip is a strong tool for dealing with/managing Python packages. If you’re working on a specific project, consider using Python Virtual Environment to install packages in an isolated location, preventing issues caused by shared dependencies and libraries. To install pip3 on Debian 12, update the package list, and install Python3 (which includes pip3) via the “sudo apt install python3-pip” command. For verification of pip3, check its version via the “pip3 –version” command. This guide has discussed the installation of pip3, and python3 as well as the removal on Debian 12.

Print Friendly, PDF & Email
Categories