The pip3 is the command line tool used to download and install the packages from the PyPI (Python Packages Index). The PyPI is the repository that contains hundreds of Python packages and libraries that enable Python developers to work efficiently.
Users can download and install the packages either directly from the PyPI official website or by using the pip3 command line utility. The pip3 is the advanced release of the pip package for managing the Python packages in different operating systems including Linux distributions.
This blog will explore the methods for the installation of pip3 on Debian 12 and also cover the following topics:
- What is the Comparison between pip and pip3
- How do I check if pip3 is installed on my Debian system
- How to Install pip3 on Debian
- Method 1: Install pip3 on Debian Using its Default Repository
- Method 2: Install pip3 on Debian by Downloading the Python Script
- How to Fix “Error: externally-managed-environment” in Debian
- What are the Commands for Managing the Python Packages Using the pip3 on Debian
- How to Uninstall the pip3 on Debian
Let’s start the blog by finding out the differences between the pip and pip3 command line tools.
What is the Comparison between pip and pip3?
The differences between the pip and pip3 command line utilities are explained below in the table:
|The pip is the command line tool to manage the packages of the Python2
|The pip3 is the package installer for the Python3 packages
|The pip has been depreciated as nowadays, the Python3 version is up to date
|The pip3 is the up-to-date package installer for the Python3 packages
|The pip package can be installed on Debian 12 by following the mentioned blog
|The pip3 package can be installed on Debian 12 by following the instructions explained in the next sections of this blog
How do I Check if pip3 is Installed on my Debian System?
To verify the installation of the pip3 package installer on Debian, open the terminal and run the command:
$ pip3 --version
If the pip3 command is not found then install it by following the steps explained in the next section.
How to Install pip3 on Debian?
There are two installation methods of pip3 on Debian 12, one is by using the package from the default repository of Debian and another is by downloading its installation script.
Method 1: Install pip3 on Debian Using the Default Repository
Hundreds of packages come with the installation of the Debian including the package pip3 which can be managed using the apt package manager.
To install the pip3 on Debian 12 using the default repository, follow the steps below.
Step 1: Open the Terminal
Launch the terminal using the CTRL+ALT+T shortcut key or searching from the application’s menu:
Step 2: Update the Packages
Execute the apt command’s “update” option to ensure all the packages are up to date:
$ sudo apt update
Step 3: Install the Python3
We know that the pip3 package installer is associated with Python3. First, install the Python3 package with the below-mentioned command:
$ sudo apt install python3 -y
Verify the installation of the python3 by displaying its version with the command:
$ python3 --version
Step 4: Install the pip3 on Debian 12
After installing Python3 on Debian 12, execute the apt command with its “install” option for the installation of pip3 on Debian 12:
$ sudo apt install python3-pip -y
Step 5: Verify the Installation of Pip3
When the installation command is executed successfully, verify the installation by displaying the version of the pip3:
$ pip3 --version
The pip3 package has been installed successfully on Debian 12.
Method 2: Install pip3 on Debian by Downloading the Python Script
Another method for installing the pip3 on Debian is by downloading its Python installation script from Bootstrap. Follow the steps mentioned below for installing the pip3 using its Python installation Script.
Step 1: Download the Python Installation Script
First download the Python installation script for the “pip3” using the wget command:
$ wget https://bootstrap.pypa.io/get-pip.py
Confirm the downloading of the Python script with the ls command:
Step 2: Run the Python Installation Script
Now using Python, run the downloaded script for the installation of the pip3:
$ python3 get-pip.py
This means that the pip3 package has successfully installed Debian 12.
How to Fix “Error: externally-managed-environment” in Debian?
Sometimes users might face the error on the screen while running the pip3 commands on the screen.
The “error: externally-managed-environment” in th Debian 12 can be resolved by following the methods:
- Run the pip3 commands in an external virtual environment
- Delete the “externally-managed” file
- Use the pipx command utility
Fix 1: Run the pip3 Commands in an External Virtual Environment
The pip3 command is used to manage the Python packages and it is recommended to create a separate External Virtual environment for the Python projects. To create a new Python virtual environment, follow the below-mentioned syntax:
$ python3 -m venv [virtual environment name]
When the virtual environment is created, activate it by the following general syntax:
$ source [virtual environment name]/bin/activate
Now run the pip3 commands without facing any error on the screen. When the pip3 usage is completed, then exit from the virtual environment by running the command:
Fix 2: Delete the “externally-managed” File
Another fix to resolve the error, is simply delete the “externally-managed” file on Debian 12. Run the below-mentioned command for deleting the “externally-managed” file on Debian 12:
$ sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED
Fix 3: Use the pipx Command Utility
The alternate approach of using the pip command on Debian 12 is by using the pipx command utility. Install the pipx command utility on Debian 12 by the following command:
$ sudo apt install pipx -y
All these fixes are used to resolve the mentioned error on the screen and then use the pip3 command on Debian 12.
What are the Commands for Managing the Python Packages Using the pip3 on Debian?
The pip3 package manager is used for managing the Python packages from the PyPI and different options of the pip3 command are used to manage the Python packages. All these options are explained with the examples.
Installation of the Python Package
To install the Python package with the pip3 command, use its “install” option as shown:
$ sudo pip3 install wheel
Installation of the Specific Version Python Package
To install the specific version of the Python package, follow the below-mentioned general syntax of the pip3 package:
$ sudo pip3 [package_name==version]
Replace the “package name” with the actual package of the Python package and “version” with its specific version.
Download the Python Packages
Use the “download” option of the pip3 command to download the Python packages. For example, run the next command for downloading the “six” Python package using the pip3 command:
$ pip3 download six
Listing Down the Python Packages
The installed Python packages can be listed down by running the “list” option of the pip3 command as shown:
$ pip3 list
All the installed packages on Debian 12 have been displayed on the screen.
Display the Information of the Installed Python Package
$ sudo pip3 show six
Detailed information on the installed “six” Python package has been displayed on the screen.
Uninstallation of the Python Package
Use the “uninstall” option of the pip3 command to uninstall the Python package, for example, run the below-mentioned command to uninstall the “lxml” package:
$ sudo pip3 uninstall lxml
The Python package “lxml” has been uninstalled successfully.
How to Uninstall the pip3 on Debian?
To uninstall the pip3 package on Debian 12, use the “purge” option of the apt command as this option will uninstall the package along with all its configuration files on Debian 12:
$ sudo apt purge python3-pip -y
To confirm the succesful execution of the above command, display the version of the pip3:
$ pip3 --version
This means the package of the “pip3” has been uninstalled successfully on Debian 12.
To install the pip3 package installer on Debian 12, run the “sudo apt install python3-pip -y” command after launching the terminal. Pip3 is used to manage the Python packages on Debian and this post explained the installation, usage, and uninstallation of the pip3 on Debian 12. Also, the difference between the pip and pip3 is explained.