Unable to locate package python-pip Ubuntu 20.04
Solution 1
Pip for Python 2 is not included in the Ubuntu 20.04 repositories.
You need to install pip for Python 2 using the get-pip.py script.
1. Start by enabling the universe repository:
sudo add-apt-repository universe
2. Update the packages index and install Python 2:
sudo apt update
sudo apt install python2
3. Use curl to download the get-pip.py script:
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
4. Once the repository is enabled, run the script as sudo user with python2 to install pip :
sudo python2 get-pip.py
If an error occurs, as a fallback, the specific 2.7 version of get-pip.py can be used:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
Pip will be installed globally. If you want to install it only for your user, run the command without sudo. The script will also install setuptools and wheel, which allow you to install source distributions
Verify the installation by printing the pip version number:
pip2 --version
The output will look something like this:
pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Solution 2
Since Python 2 is past its end-of-life, few packages for Python2 are included in 20.04. You have to install pip
for Python 2 manually:
First, install Python 2:
sudo apt install python2
Then, follow https://pip.pypa.io/en/stable/installing/ , using python2
:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python2 get-pip.py
You can run the second step with sudo
. If you don't use sudo
, you'll need to change PATH
, as suggested by the installation message. Alternatively, and possibly better (since it doesn't change PATH
), use
python2 -m pip
whenever you need pip2.
Solution 3
In my case, the curl command for downloading get-pip.py
gave a syntax error on running sudo python get-pip.py
.
But manual download by visiting https://bootstrap.pypa.io/ and downloading get-pip.py
worked fine for me.
Solution 4
I've found that creating a virtualenv
for Python 2.7 installs also pip
$ virtualenv -p python2 venv
$ . venv/bin/activate
$ pip --version
pip 20.0.2 from /home/.../venv/lib/python2.7/site-packages/pip (python 2.7)
Captain_Dev88
Updated on July 10, 2021Comments
-
Captain_Dev88 almost 3 years
I am trying to install mininet-wifi. After downloading it, I have been using the following command to install it:
sudo util/install.sh -Wlnfv
However, I keep getting the error:
E: Unable to locate package python-pip
I have tried multiple times to download python-pip. I know mininet-wifi utilizes python 2 instead of python 3. I have tried to download python-pip using the command:
sudo apt-get install python-pip
But that leads to the same error:
E: Unable to locate package python-pip
-
omajid almost 4 yearsIt might be a good idea to report this as a bug against mininet-wifi. Python 2 was end-of-lifed at the beginning of this year. It won't be receiving any further bug or security fixes. Projects should be using Python 3 now.
-
phd almost 4 yearsTry repository universe: stackoverflow.com/a/55423104/7976758
-
Ramon Fontes almost 4 yearsMininet-WiFi supports Python3. This seems to be a problem with internal packages than any other thing. Worth mentioning that Ubuntu 20.04 does not (natively) support Python2 anymore. So you may want to install pip3. Unless there is a good reason to use Python2...
-
-
9769953 almost 4 yearsThe list of Python-related packages for 20.04 shows no
python-pip
package. -
Yuuty almost 4 yearsCan
python-pip-whl
not install python packages from the python package index ? -
Vic Seedoubleyew over 3 yearsI might have misunderstood: are you sure this answers the question?
-
Vic Seedoubleyew over 3 yearsIt seems to me that it only install it inside the virtual environment, doesn't it?
-
1UC1F3R616 over 3 yearsthanks, had the same issue. I think aftrer jan 2021 people are having this problem
-
sundowatch over 3 yearsThat was a great solution. Thanks. I've encountered the error you mentioned as "If an error occurs". I think the problem is with using python2.7 with Ubuntu 20.
-
a0s over 3 yearsIts not working!
root@farm:~# python --version Python 2.7.18 root@farm:~# python ./get-pip.py Traceback (most recent call last): File "./get-pip.py", line 24244, in <module> main() File "./get-pip.py", line 199, in main bootstrap(tmpdir=tmpdir) File "./get-pip.py", line 82, in bootstrap from pip._internal.cli.main import main as pip_entry_point File "/tmp/tmpc8gemv/pip.zip/pip/_internal/cli/main.py", line 60 sys.stderr.write(f"ERROR: {exc}") ^ SyntaxError: invalid syntax
-
Nwawel A Iroume about 3 years@a0s use
curl https://bootstrap.pypa.io/2.7/get-pip.py --output get-pip.py
as it has been said in the answer if you get an error. -
Tasneem almost 3 yearsDone all the above commands. In my case pip3 has been installed but the error still exists