# Installing Python 3.10, Pip, and Venv on Ubuntu

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

```bash
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:

```bash
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:

```plaintext
sudo add-apt-repository ppa:deadsnakes/ppa
```

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

```bash
sudo apt install python3.10
```

Confirm the successful installation by checking the Python version:

```plaintext
python3.10 --version
```

### **Installing Pip for Python 3.10**

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

```plaintext
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
```

We then confirm the pip installation:

```plaintext
python3.10 -m pip --version
```

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

```plaintext
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:

```plaintext
sudo apt install python3.10-venv
```

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

```plaintext
python3.10 -m venv .venv
```

Lastly, we activate the created virtual environment:

```plaintext
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:

```plaintext
javascriptCopy codeTraceback (most recent call last):
  ...
  File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", 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/__init__.py)
```

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