Installing Python 3.10, Pip, and Venv on Ubuntu

The following guide will help you install python 3.10, pip, and venv on Ubuntu.

Start by updating the system's package lists with the following command:

sudo apt update && sudo apt upgrade -y

Next, we install the software-properties-common package, which provides the ability to easily manage your distribution and independent software vendor software sources:

sudo apt install software-properties-common -y

Adding Deadsnakes PPA and Installing Python 3.10

The Deadsnakes PPA is a repository that provides newer Python versions not available in the official Ubuntu repositories. We add it to our sources list with:

sudo add-apt-repository ppa:deadsnakes/ppa

We then install Python 3.10 from the added PPA(Personal Package Archive):

sudo apt install python3.10

Confirm the successful installation by checking the Python version:

python3.10 --version

Installing Pip for Python 3.10

We fetch the pip installer and install it using Python 3.10:

curl -sS | python3.10

We then confirm the pip installation:

python3.10 -m pip --version

To ensure we have the latest version of pip, we upgrade it:

python3.10 -m pip install --upgrade pip

Installing venv and Creating a Virtual Environment

We install the Python module venv, which is used to create lightweight virtual environments:

sudo apt install python3.10-venv

Next, we create a new virtual environment named ".venv":

python3.10 -m venv .venv

Lastly, we activate the created virtual environment:

source .venv/bin/activate

That's it, you should be good to go

Possible Errors

If you only run the first command sudo apt install python3.10 without the following commands which help install the correct version of pip, you may get an error such as the following:

javascriptCopy codeTraceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/index/", line 12, in <module>
    from pip._vendor import html5lib, requests
ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/

If you want a specific topic covered, please leave it in the comments.

Did you find this article valuable?

Support crushingCodes by becoming a sponsor. Any amount is appreciated!