Having issues installing Python packages? Seeing the error “Package ‘python-pip’ has no installation candidate” when trying to install pip or other Python packages on Linux? Not to worry – this common error can be easily fixed.
The E: Package ‘python-pip’ has no installation candidate error occurs when trying to install Python packages through the system package manager (like apt or apt-get). Still, the package repository does not contain the requested Python package.
What Causes This Error?
Before jumping into the solutions, it’s good to understand what leads to this error in the first place:
- Outdated Repositories – The repositories configured on your Linux system are outdated and do not contain metadata about the latest versions of Python packages available. This happens if you haven’t run
apt updatein a while.
- Disabled or Missing Repositories – Sometimes the repository that contains Python packages may be disabled or missing from your sources list. This leads to the package manager being unable to locate the requested Python package.
- Unsupported Distribution – Some Linux distributions have custom ways of packaging Python add-ons or may name packages differently. If you try to install using the wrong package name, you’ll see the no installation candidate error.
- Architecture Mismatch – Trying to install a Python package that is built only for a different architecture (32-bit vs 64-bit) will result in this error.
- Network Connectivity Issues – Package managers need internet access to reach out to repositories and download packages. Lack of network connectivity hampers this ability.
No need to panic! Here are the top methods to resolve this error and successfully install Python packages like pip on Linux.
Prerequisites – Update Package Index
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.
Method 1 – Install python3-pip for Python 3
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:
Method 2 – Install python-pip for Python 2
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:
Method 3 – Enable Universe Repository
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.
Method 4 – Install Pip via get-pip.py
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:
- Search online for directions on configuring Python package management specific to your Linux distribution and version
- Ensure your internet connectivity works and networking is not blocking access to repositories
- Try changing download mirrors in case an issue exists for the mirror being used
- Seek community support via Ubuntu/Debian forums, Stack Overflow etc. if the problem seems persistent
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!