One of the countless features that Linux provides is the ability to install any software using just the terminal on the system. Regardless not every software is present in the apt repository to be installed. The python-pip tool is utilized to install a wider variety of packages related to python. The python-pip tool itself needs to be installed from the apt repository first. During this installation process, the “Unable to locate package python-pip” error can be invoked by the system.
This article will provide all the necessary information about this error including its reasons and how to resolve this problem.
Resolve the problem “Unable to locate package python-pip”
This error is encountered when trying to install the python-pip package. There are different reasons surrounding this installation that can cause the error. This section will deal with all the possible reasons for the error and their corresponding solutions.
Reason: Python-pip is Not Found
The most simple explanation for why this error is invoked is that the apt installer can not locate the package python-pip. There are a few different solutions that will help the terminal to locate the correct package as well as resolve the error.
Solution 1: Check Python Version and Use Correct Syntax
The most suitable way to resolve the issue is to use a slightly different command to install the pip tool. To know the correct syntax, the system’s Python version needs to be checked. To know which version of Python the system is running, try the following commands:
$ python2 --version $ python3 --version
The command corresponding to the Python version will execute and display the version as shown in the image below:
Once the Python version is known, use the corresponding syntax to install the pip tool. The sample commands are given below.
If the system is running Python version 2 use this command:
$ sudo apt install python2-pip
If the system is running Python version 3 use this command:
$ sudo apt install python3-pip
This change in the syntax should successfully remove the “Unable to locate package python-pip” issue from the system and python-pip will be installed.
Solution 2: Use the Universe Repository
The python-pip package can be found inside the Universe repository. This is another repository that contains a lot of different software which are free to download. All these software are also opensource that are If your system is not equipped with the Universe repository then you can add it using the following commands:
$ sudo apt-get install software-properties-common $ sudo apt-add-repository universe $ sudo apt-get update
Once the Universe repository is added successfully as shown in the snippet above, the python-pip command can easily be executed as follows:
$ sudo apt install python-pip
By following this, the “Unable to locate package python-pip” error will be resolved and the python-pip package can be installed easily.
The “Unable to locate package python-pip” error occurs when the apt installer is unable to locate a package inside its repository. To fix this, there are two methods. One is to use the correct syntax corresponding with the python version installed on your system. The other method is to add the Universe repository to your system. This contains the python-pip package. Here, you have learned about the reason and the possible solutions to the error “unable to locate package python-pip”.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY