If you encounter the error “pip has no installation candidate” in Python, don’t worry. This article will help you fix it with easy steps and explanations.
Before jumping into the solutions, it’s good to understand what leads to this error in the first place:
apt update
in a while.No need to panic! Here are the top methods to resolve this error and successfully install Python packages like pip on Linux.
Also read: How to Fix “Function is Not Defined” Error in Python
First, update the package index to refresh repository information:
sudo apt update
This fetches the latest package listings from all configured repositories and refreshes the package database.
Why is this important before trying to install anything?
The update ensures that your package manager has latest metadata and awareness of package versions available in the repositories. Without this, attempts to install a particular package can fail.
Recent Ubuntu and Debian versions ship with Python 3 pre-installed. Try installing the Python 3 version of pip:
sudo apt install python3-pip
This will install the pip package for Python 3.x.
Verify successful installation with:
pip3 --version
On older systems with Python 2 as default, install the python-pip package instead:
sudo apt install python-pip
Check if pip is now available for Python 2:
pip --version
If install fails again, the issue could be that the Python package repository is disabled or missing. Enable the Universe repository:
sudo add-apt-repository universe
We’ll update the repositories again using the apt update command on our terminal.
sudo apt update
With Universe enabled, attempt installing python3-pip or python-pip again. This should resolve the problem in many cases.
As an alternative, install pip manually by downloading the get-pip Python script:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then run it with sudo:
sudo python get-pip.py
This will install pip globally regardless of whether the pip package exists in repositories or not.
Some other things you can try if the above steps don’t help:
Using the methods above should be sufficient to resolve the “Package ‘python-pip’ has no installation candidate” error in most cases though. Let me know if any part of the guide needs more explanation!
These simple steps will help resolve the “E: Package ‘python-pip’ has no installation candidate” issue and install pip on any Linux distribution. Let us know if you have any other questions!