"E: Unable to Locate Package Python-Pip" on Ubuntu 18.04

E: Unable to locate package python-pip on Ubuntu 18.04

Try following command sequence on Ubuntu terminal:

sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install python-pip

Unable to locate package python-pip Ubuntu 20.04

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)

Not able to install 'pip3' in ubantu

The first procedure you followed is correct

sudo apt-get -y install python3-pip
But before installing try to update using command

sudo apt-get update

If first did not work then you can also do this using curl

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python3 get-pip.py --user

if above not work:

curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python

Then to verify installation try

pip3 --help

For checking version :

pip3 --version

How do I install pip for python 3.8 on Ubuntu without changing any defaults?

While we can use pip directly as a Python module (the recommended way):

python -m pip --version

This is how I installed it (so it can be called directly):

Firstly, make sure that command pip is available and it isn't being used by pip for Python 2.7

sudo apt remove python-pip

Now if you write pip in the Terminal, you'll get that nothing is installed there:

pip --version

Output:

Command 'pip' not found, but can be installed with:

sudo apt install python-pip

Install python3.8 and setup up correct version on python command using update-alternatives (as done in the question).

Make sure, you have python3-pip installed:

(This won't work without python3-pip. Although this will install pip 9.0.1 from python 3.6, we'll need it.)

sudo apt install python3-pip

This will install pip 9.0.1 as pip3:

pip3 --version

Output:

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Now, to install pip for Python 3.8, I used pip by calling it as a python module (ironic!):

python -m pip install pip

Output:

Collecting pip

  Downloading https://files.pythonhosted.org/packages/36/74/38c2410d688ac7b48afa07d413674afc1f903c1c1f854de51dc8eb2367a5/pip-20.2-py2.py3-none-any.whl (1.5MB)

  100% |████████████████████████████████| 1.5MB 288kB/s

Installing collected packages: pip

Successfully installed pip-20.2

It looks like, when I called pip (which was installed for Python 3.6, BTW) as a module of Python 3.8, and installed pip, it actually worked.

Now, make sure your ~/.local/bin directory is set in PATH environment variable:

Open ~/.bashrc using your favourite editor (if you're using zsh, replace .bashrc with .zshrc)

nano ~/.bashrc

And paste the following at the end of the file

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

Finally, source your .bashrc (or restart the Terminal window):

source ~/.bashrc

Now if you try running pip directly it'll give you the correct version:

pip --version

Output:

pip 20.2 from /home/qumber/.local/lib/python3.8/site-packages/pip (python 3.8)

Sweet!

Install pip on Ubuntu server 18.04.1 LTS

This is how I personally install pip, instead of worrying about the headache of finding it on various package managers.

curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

Then use pip from python3 like so:

sudo python3 -m pip install <packagename>

Ubuntu 18.04 sudo apt-get install python2 results in E: Unable to locate package python2

After searching the Ubuntu packages, it seems that for some odd reason for Ubuntu 20.04 the name of the Python 2 package is python2 but for Ubuntu 18.04 there is no package named python2. It seems that for Ubuntu 18.04 by running:

sudo apt-get install python-pip

This installs both pip for Python 2 and Python 2 itself, so this seems to be the best option

E: unable to locate package pip

In Ubuntu, pip is provided by the python-pip package. You can install it in the Software Center, or, if you prefer to use the command line:

sudo apt-get update && sudo apt-get install python-pip

If you have not already installed python-dev and build-essential, you should install them too. (But it seems your apt-get command might have successfully installed them. If you're not sure, you can check by trying to install them again. Or with apt-cache policy python-dev build-essential.)

Once the necessary software is installed, if you wish to update it further, you can do so with pip itself, by running:

sudo pip install --upgrade pip 
sudo pip install --upgrade virtualenv

Source: How to install pip on Ubuntu by Eliot (dated, but should still apply).

How to Install pip for python 3.7 on Ubuntu 18?

In general, don't do this:

pip install package

because, as you have correctly noticed, it's not clear what Python version you're installing package for.

Instead, if you want to install package for Python 3.7, do this:

python3.7 -m pip install package

Replace package with the name of whatever you're trying to install.

Took me a surprisingly long time to figure it out, too. The docs about it are here.

Your other option is to set up a virtual environment. Once your virtual environment is active, executable names like python and pip will point to the correct ones.



Related Topics



Leave a reply



Submit