Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to locate package python-pip Ubuntu 20.04

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
like image 326
Captain_Dev88 Avatar asked May 24 '20 03:05

Captain_Dev88


People also ask

How do I fix Python unable to locate a package?

To Solve Unable to locate package python-pip Error Just follow these command step by step: sudo apt-get install software-properties-common Then run this command: sudo apt-add-repository universe Now, sudo apt-get update Then sudo apt-get install python-pip Second solution is You just need to Identify version that ...

Where is Python packages install in Ubuntu?

A non-Debian Python installation, such as Python compiled from source, will install Python packages into /usr/local/lib/pythonX. Y/site-packages by default, where X.Y is your Python version (such as 2.7 ).

Why is pip install not working in Python?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.


3 Answers

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)
like image 50
muhive Avatar answered Oct 16 '22 21:10

muhive


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.

like image 5
9769953 Avatar answered Oct 16 '22 21:10

9769953


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.

like image 3
Sanket Hire Avatar answered Oct 16 '22 19:10

Sanket Hire