How to install pip for Python 3.9 on Ubuntu 20.04

We Are Going To Discuss About How to install pip for Python 3.9 on Ubuntu 20.04. So lets Start this Python Article.

How to install pip for Python 3.9 on Ubuntu 20.04

  1. How to solve 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.

  2. 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.

Solution 1

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.

Original Author Shane Bishop Of This Content

Solution 2

An alternative that relies only on deadsnakes/ppa is to install python3.9-venv.

sudo apt-get install python3.9-venv
python3.9 -m venv venv
source venv/bin/activate
pip --version
# pip 21.1.3 from /home/.../venv/lib/python3.9/site-packages/pip (python 3.9)

Perhaps easier to keep coherent over time, but forcing into Virtualenv.


This method was born out a problem on Ubuntu 18. Other proposals in the thread aimed at OP’s target (20.04) did not work. The install script from PyPa ends on Ubuntu 18 with:

python3.9 get-pip.py
# ...
# AttributeError: 'HTMLParser' object has no attribute 'unescape'

Original Author Eric Platon Of This Content

Solution 3

Pip is included by default in python 3.4 and later.

python3.9 -m pip --version

If, for some reason, pip is not installed, you can install it manually by using get-pip:

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

Original Author dellitsni Of This Content

Solution 4

If anyone else is running into seemingly bizarre WSL2 behavior from their pips, TechDog’s suggestion fixed my WSL2 Ubuntu 20.04. It was the update-alternatives line, exactly as TechDog posted, that did the trick!

update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1

Original Author Gnubesoft Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment