Software & AppsOperating SystemLinux

How To Install Python 3.7 Packages in Ubuntu 20.04

Ubuntu 10

In this comprehensive guide, we will walk you through the process of installing Python 3.7 packages in Ubuntu 20.04. Python is a high-level, interpreted programming language known for its simplicity and versatility. While Ubuntu 20.04 comes with Python 3.8 by default, there may be instances where you need to use Python 3.7.

Quick Answer

To install Python 3.7 packages in Ubuntu 20.04, you can use the Deadsnakes PPA repository or manually install Python 3.7 from a tarball. The Deadsnakes PPA method allows you to easily add the repository and install the packages with a few commands. If the PPA method doesn’t work for you or you prefer manual installation, you can download the Python 3.7 tarball from the official Python website and follow the steps to install it.

Method 1: Using Deadsnakes PPA

The Deadsnakes PPA is a popular repository that provides newer and older versions of Python, which aren’t available in the default Ubuntu repositories.

Step 1: Add the Deadsnakes PPA

Open your terminal and execute the following commands to add the Deadsnakes PPA to your system:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update

The add-apt-repository command adds the PPA to your system’s software sources. The sudo keyword is used to execute the command with root privileges. The apt update command is used to update the package list.

Step 2: Install Python 3.7 Packages

Once you have added the Deadsnakes PPA, you can install the Python 3.7 packages with the following command:

sudo apt install python3.7-venv python3.7-dev

The apt install command installs the specified packages. The python3.7-venv package provides support for creating lightweight “virtual environments†with their own site directories, optionally isolated from system site directories. The python3.7-dev package contains the header files you need to build Python extensions.

Method 2: Manual Installation from Tarball

If you prefer manual installation, or if the Deadsnakes PPA method doesn’t work for you, you can download the Python 3.7 tarball from the official Python website and install it.

Step 1: Download the Tarball

Use the wget command to download the tarball:


The wget command is a free utility for non-interactive download of files from the web. It supports HTTP, HTTPS, and FTP protocols.

Step 2: Extract the Tarball

Once the download is complete, extract the tarball with the tar command:

tar -xvzf Python-3.7.7.tgz

The -xvzf flags tell tar to eXtract the archive, be Verbose (show the files being extracted), use gZip to decompress the archive, and the File to be extracted is following.

Step 3: Install Python 3.7

Navigate to the extracted directory and install Python 3.7:

cd Python-3.7.7
sudo make install

The cd command changes the current directory. The ./configure script checks whether your system has all the necessary packages to compile and install Python. The make command compiles the source code. The sudo make install command installs the compiled code to your system.

Step 4: Install Python 3.7 Packages

After installing Python 3.7, install the Python 3.7 packages:

sudo apt install python3.7-venv python3.7-dev


In this guide, we have shown you two methods to install Python 3.7 packages in Ubuntu 20.04. You can either use the Deadsnakes PPA or manually install Python 3.7 from a tarball. Remember to choose the method that best fits your needs and preferences. Happy coding!

Can I have both Python 3.8 and Python 3.7 installed on Ubuntu 20.04?

Yes, you can have multiple versions of Python installed on your Ubuntu 20.04 system. By default, Ubuntu 20.04 comes with Python 3.8 installed. You can follow the instructions in this guide to install Python 3.7 alongside Python 3.8.

How can I switch between Python 3.8 and Python 3.7?

To switch between Python versions, you can use the update-alternatives command. For example, to switch to Python 3.7, you can run sudo update-alternatives --config python3 and select the desired Python version from the available options.

Can I uninstall Python 3.7 after installing it using the Deadsnakes PPA?

Yes, you can uninstall Python 3.7 by running sudo apt remove python3.7-venv python3.7-dev. This will remove the Python 3.7 packages installed from the Deadsnakes PPA. However, please exercise caution when removing packages, as it may affect any applications or scripts that rely on Python 3.7.

Can I install Python packages using pip after installing Python 3.7?

Yes, after installing Python 3.7, you can use pip to install Python packages specific to that version. You can use the command pip3.7 install <package-name> to install packages for Python 3.7.

Leave a Comment

Your email address will not be published. Required fields are marked *