. Advertisement .
. Advertisement .
As you know, pip is a package manager for python, used by many projects to manage dependencies. It is integrated into the python installation, making it an essential tool for everyone to use. However, for new users, it will still be difficult to install it. If you face this situation “Unable to locate package python-pip“, refer to the workarounds below to find out how to solve it.
When do you get the error “Unable to locate package python-pip”?
There are many ways to install python-pip. However, in this situation, when you used the command line “sudo apt install python-pip” to run, this error happened. It is displayed as below:
$ pip Command 'pip' not found, but can be installed with: sudo apt install python-pip $ sudo apt install python-pip [sudo] password for aiki: Reading package lists… Done Building dependency tree Reading state information… Done C: Unable to locate package python-pip
Here we will give you some solutions when encountering this error. Each error will be appropriate for each different version you are using. Please read the article carefully and choose the most suitable option.
How to solve the error “Unable to locate package python-pip”?
Solution 1: Tweak a bit about the statement you are using
With the first method, you need to tweak a bit about the statement you are using.
sudo apt-get install software-properties-common
Next, run program with the line below:
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install python-pip
After completing the above steps, check again if the error is fixed or not.
Solution 2: Run the command below
As said above, this error usually occurs due to the difference between python versions you are using. To check which version you are using, run the command below:
After checking, if the version you installed is Python 2.X, let’s use the line below:
sudo apt-get install python2-pip
For Python 3.X:
sudo apt-get install python3-pip
After you have finished running the above command line, now please check to see if the error has been fixed.
Solution 3: If you don’t have curl, install it
The next method would involve curl. Double check, if you don’t have curl, install it:
apt-get install curl
then run the program in turn with the command lines indicated below for the error to be handled.
https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Solution 4: To reset
The last way to solve the error “Unable to locate package python-pip” is to reset. If the command prompt is closed, let’s “launch” it by this way.
Type “cmd” in the Windows search bar, click the icon that appears.
Continue running command line “curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py” to download get-pip.py file.
Next, enter this line: python get-pip.py
To check if you have installed it correctly or not, use the command: pip help.
Complete the steps and your error has been resolved.
Solution 5: Utilize the ensurepip module
Utilizing the ensurepip module is a great way for you to solve the error “Unable to locate package python-pip”. There is a built-in method in Python to verify that pip is installed. However, it’s unlikely to function if you’re using Ubuntu or Debian because these operating systems typically disable it. Or, at the very least, every time I do this, it is deactivated. However, it’s worth a try.
python -m ensurepip --upgrade
You’ll probably see the following error message or a variation of it:
ensurepip is disabled in Debian/Ubuntu for the system python. Python modules for the system python are usually handled by dpkg and apt-get. apt install python3-<module name> Install the python3-pip package to use pip itself. Using pip together with the system python might have unexpected results for any system installed module, so use it on your own risk, or make sure to only use it in virtual environments.
Let’s move on to your last resort: using the get-pip script.
Our article gave information related to pip and how to fix the “Unable to locate package python-pip” error. If your problem is still not resolved, do not hesitate to contact us to get it answered.