How to Install Python Package Installer Pip on Ubuntu 20.04 Linux

How to install Python package installer PIP on Ubuntu 20.04 Linux

Option 1

1.vim /etc/apt/sources.list

2.add these lines in the above file.

   deb http://http.kali.org/kali kali-rolling main non-free contribs
deb http://kali.cs.nctu.edu.tw/kali kali-rolling main contrib non-free
deb-src http://http.kali.org/kali kali-rolling main non-free contrib

  1. sudo apt update

  2. sudo apt install python3-pip

Option 2

sudo apt-get update
sudo apt-get upgrade
sudo apt install python3-pip

Option 3
https://stackoverflow.com/a/59922280/11741464

Source:
facing problem in kali linuix python3-pip

How to install pip for Python 3.9 on Ubuntu 20.04

You can install pip for python 3.9 the following way:

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

It is important you use python3.9 instead of just python3, to ensure pip is installed for python 3.9.

If you see any permissions errors, you may need to use

python3.9 get-pip.py --user

If you get an error like No module named 'distutils.util' when you run python3.9 get-pip.py, and you are on a Debian-based Linux distribution, run

sudo apt install python3.9-distutils

and then rerun your get-pip.py command. If you are not on a Debian-based distribution, use the equivalent command for your distribution's package manager.

These instructions are based in part on the official installation instructions provided by the pip maintainers.


This portion of my answer is a bit out of the scope of the question, since the question is specifically for python 3.9. However, for anyone trying to install pip on python 3.6 or older, at the time of writing the file at https://bootstrap.pypa.io/get-pip.py only supports python 3.7 or newer.

The workaround is to instead download from https://bootstrap.pypa.io/pip/<python version>/get-pip.py instead. For example, if you want to install pip for python 3.6, then you can download from https://bootstrap.pypa.io/pip/3.6/get-pip.py, and then follow all of the steps above as usual.

How can I install pip for Python2.7 in Ubuntu 20.04

Pip for Python 2 is not included in the Ubuntu 20.04 repositories.

Try this guide which suggests to fetch a Python 2.7 compatible get_pip.py and use that to bootstrap pip.

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

How to install pip globally on Ubuntu 20.04, so that all users can use it the same way?

bash: /usr/bin/pip3: No such file or directory

This is because bash still remembers where it saw pip3 last time and the place was changed from /usr/bin/pip3 to /usr/local/bin/pip3. To clear its memory run hash -r. See command hash in bash manual.

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)

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!



Related Topics



Leave a reply



Submit