How to Uninstall Python 3.7 from Ubuntu

Uninstall Python 3 7 From Ubuntu

Have you ever installed a version of Python on your Ubuntu system that you no longer need or want? Uninstalling unneeded Python versions helps free up disk space and reduces clutter.

Python is one of the most versatile and widely-used programming languages used today for various software development, data analysis, machine learning, scientific computing and more. As new versions of Python are released, users may want to upgrade or uninstall old versions from their Ubuntu systems to take advantage of new features or start fresh.

But over time, as projects and Python packages upgrade, you may find old Python versions accumulate on your Ubuntu device. If you installed Python 3.7 for a specific project but no longer need it, uninstalling clears disk space and simplifies environment management.

In this comprehensive guide, we will walk through the necessary steps to fully purge Python 3.7 from an Ubuntu system to clean up space or prepare for an upgrade to Python 3.12.x.

Also read: Downgrade From Python 3.7 to 3.6 on Windows, MacOS, and Linux


When removing software in Linux, it is critical to remove all associated files, directories, caches, libraries, binaries and other dependencies to have a clean uninstall. This is especially important for a programming language like Python that has been installed via binaries, source code, and extensions.

First, let’s verify which Python versions are installed on the system. This will allow us to confirm we remove the correct one.

  • Which Python versions are on your Ubuntu system
  • Whether any active projects or packages still require Python 3.7

Open your terminal and type:

Image 2
Python version check

In my case, I don’t have python 3.7 installed but my default is 3.11. However, you may see 3.7.x and may want to follow through the installation process.


python2 --version

This displays your default Python 3 and Python 2 versions.

Next, check your available Python installs:

ls -l /usr/bin/python*

Image 3
File location check

Scan the output for any python3.7 executables. If python3.7 shows up but is not your default Python 3, you can uninstall.

Key Point: To prevent breakages, avoid uninstalling Python versions still in use by projects.

Step 1 – Fully Remove the Python 3.7 Interpreter

Now that the installed Python versions are confirmed, we can remove Python 3.7. Since this version was likely installed using the Ubuntu apt package manager, we can use apt to uninstall the Python 3.7 binaries and Debian packages.

Run the following apt remove command:

sudo apt purge python3.7\*

You will be prompted for your account sudo password. Enter it to proceed.

This apt remove command will begin eliminating the core Python 3.7 executable packages, including the developer, virtual environment, tkinter GUI, and dbm database library files.

Note: Some additional Python 3.7 packages may be installed on your system if you installed third-party extensions. You can run dpkg –get-selections | grep python3.7 to check for any additional related packages to remove.

Double-check by listing Python versions again:

ls -l /usr/bin/python* 

Python 3.7 should no longer appear.

Also read: Installing Python in Alpine Linux

Step 2 – Delete Any Remaining Python 3.7 Files

Next we clean up any remaining files or folders related to the now-removed Python 3.7 installation:

cd /usr/local/lib/python3.7
sudo rm -r /usr/local/lib/python3.7

The first command navigates into the Python 3.7 folder, and the second deletes it. Repeat this for any other Python 3.7 directories found under /usr/local/lib.

We also need to delete the idle3.7 folder which contains IDE files for working with Python 3.7:

sudo rm -rf /usr/local/bin/idle3.7

Use the full path for any other idle3.7 references found on your system. Finally, remove the Python 3.7 dist-packages folder:

sudo rm -r /usr/local/lib/python3.7/dist-packages

Step 3 – Update Environment Paths

The last step is updating any environment paths pointing to the now-eliminated Python 3.7 executable.

Open (or create) a .bashrc file:

nano ~/.bashrc

Check for lines referencing python3.7. If a line like this exists in your bashrc, just comment or delete it completely.

export PATH="/usr/local/bin/python3.7:${PATH}"

Delete references specifically pointing to 3.7. Save and close the file.


And that’s it – you have fully uninstalled Python 3.7 from your Ubuntu system! Following this process, you’ve:

  • Purged all python3.7 packages
  • Removed all files and folders associated with the installation
  • Updated environment variables and paths pointing to python3.7

Removing old Python versions helps minimize clutter and wasted disk space. With this guide, you now have a streamlined approach to uninstalling unneeded Python versions like 3.7 from Ubuntu.