Remove Python 3.14 or 3.15 on Ubuntu Without Breaking system python3

Tech reviewed: Deepak Prasad
Remove Python 3.14 or 3.15 on Ubuntu Without Breaking system python3

You installed Python 3.14 or 3.15 alongside Ubuntu’s system python3—for example with the Deadsnakes PPA or source altinstall. When you no longer need that extra version, remove only what you added. Do not purge Ubuntu’s default python3 package to “uninstall Python” on the whole system.

This guide routes uninstall steps by how the interpreter was installed, verifies that apt and system python3 still work, and covers virtualenv cleanup.

Tested on: Python 3.14.6 source altinstall remove and reinstall; system python3 3.13.3; kernel 6.14.0-37-generic; Ubuntu 25.04.

The source altinstall uninstall block, venv create/delete, and post-removal checks below were run on this host (python3.14 at /usr/local/bin, then removed, then reinstalled to /usr/local/bin/python3.14 with venv at ~/venvs/py314). Deadsnakes apt remove --purge commands match package names on Launchpad for jammy and noble; that purge path was not re-run here because this VM is Ubuntu 25.04 (plucky), which the PPA does not publish.


Which removal path should you use?

How it was installed What to remove Leave alone
Deadsnakes PPA python3.14 / python3.15 apt packages python3, python3-minimal, libpython3* from Ubuntu
Source make altinstall Files under /usr/local for that version /usr/bin/python3 and /usr/lib/python3*
pyenv pyenv uninstall <version> System python3 and other pyenv versions you still need
Virtual environment only rm -rf the venv directory Any system or /usr/local interpreter you still use

Pick one major section below. Removing a venv does not uninstall the underlying Python binary.


Do not remove Ubuntu system python3

These packages (and their dependencies) must stay on a normal Ubuntu desktop or server:

  • python3
  • python3-minimal
  • libpython3-stdlib and related libpython3* packages tied to the release default

Avoid commands such as:

bash
# Do not run these on Ubuntu system Python
sudo apt remove python3
sudo apt purge python3-minimal
sudo rm /usr/bin/python3

If apt, add-apt-repository, or cloud-init break after removing system Python, reinstall the metapackages Ubuntu expects (for example sudo apt install --reinstall python3 python3-minimal) from a recovery shell or live media—not by deleting more Python packages at random.


Identify how your extra Python was installed

Replace 3.14 with 3.15 if that is the version you added.

bash
command -v python3.14
python3.14 --version 2>/dev/null
dpkg -l 'python3.14*' 2>/dev/null | grep ^ii

Example when Deadsnakes packages are installed:

text
/usr/bin/python3.14
Python 3.14.6
ii  python3.14      3.14.6-1+noble1  amd64  ...
ii  python3.14-venv ...

Example when built with source altinstall:

text
/usr/local/bin/python3.14
Python 3.14.6

If dpkg -l shows no python3.14 packages but which points to /usr/local/bin, use the source-removal section.


Remove Python installed from the Deadsnakes PPA

Use this when install latest Python on Ubuntu with sudo apt install python3.14 (or python3.15).

Python 3.14 (stable)

List related packages before removal:

bash
dpkg -l 'python3.14*' | grep ^ii

Remove the interpreter and common companion packages:

bash
sudo apt remove --purge python3.14 python3.14-venv python3.14-dev
sudo apt autoremove --purge

If dpkg -l still lists other python3.14-* packages (for example python3.14-distutils), purge them the same way.

Verify:

bash
command -v python3.14
python3 --version
sudo apt update

Expected after a clean removal on Ubuntu 24.04:

text
$ command -v python3.14
$ python3 --version
Python 3.12.3

On this host after removing a source altinstall build, verification looked like:

text
$ command -v python3.14
$ python3 --version
Python 3.13.3
$ which python3
/usr/bin/python3

(python3.14 produces no path; system python3 still reports the Ubuntu release default—3.10 on 22.04, 3.12 on 24.04, or your version on newer releases.)

Python 3.15 (pre-release)

Same flow with 3.15 package names:

bash
dpkg -l 'python3.15*' | grep ^ii
sudo apt remove --purge python3.15 python3.15-venv python3.15-dev
sudo apt autoremove --purge
command -v python3.15
python3 --version

Optional: remove the Deadsnakes PPA

Only if you uninstalled all Deadsnakes Python versions and will not install another from that archive:

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

Skip this if you still rely on the PPA for another Python line.


Remove Python installed with source altinstall

Use this when which python3.14 (or python3.15) is under /usr/local/bin after make altinstall.

List versioned files first:

bash
ls /usr/local/bin/python3.14 /usr/local/bin/pip3.14 2>/dev/null
ls -d /usr/local/lib/python3.14 /usr/local/include/python3.14 2>/dev/null

Remove binaries and libraries for that version only (example for 3.14):

bash
sudo rm -f /usr/local/bin/python3.14 /usr/local/bin/pip3.14 \
  /usr/local/bin/pydoc3.14 /usr/local/bin/idle3.14 /usr/local/bin/python3.14-config
sudo rm -rf /usr/local/lib/python3.14 /usr/local/include/python3.14
sudo rm -f /usr/local/share/man/man1/python3.14.1
sudo rm -f /usr/local/lib/libpython3.14.a /usr/local/lib/pkgconfig/python-3.14*.pc

For 3.15, substitute 3.15 in every path.

Verify:

bash
command -v python3.14
python3 --version
hash -r

Run hash -r or open a new shell so your session drops cached paths to deleted binaries.

Do not run sudo rm -rf /usr/local/bin/python3 unless you are certain you never created an unversioned python3 symlink from a manual make install.


Remove a Python version managed by pyenv

If the interpreter lives under ~/.pyenv:

bash
pyenv versions
pyenv uninstall 3.14.6

Remove .python-version in project directories that still pin the deleted release. Other pyenv versions and system python3 are unaffected.

To remove pyenv entirely (uncommon):

bash
rm -rf ~/.pyenv

Then delete pyenv init lines from ~/.bashrc or ~/.zshrc.


Remove a virtual environment (not the Python interpreter)

A venv is a directory (often under ~/venvs/). Deleting it does not uninstall python3.14 or python3.15 from the system.

Deactivate if the venv is active, then delete:

bash
deactivate 2>/dev/null || true
rm -rf ~/venvs/myproject

Update IDE interpreter settings, systemd units, cron jobs, or CI configs that pointed at that path.


Verify removal and system health

After any method above, run:

bash
python3 --version
which python3
sudo apt update
sudo apt-get check

Confirm the version you removed is gone:

bash
command -v python3.14
command -v python3.15

Optional: list remaining versioned binaries:

bash
ls /usr/bin/python3.* /usr/local/bin/python3.* 2>/dev/null

System python3 should still exist; the removed version should not.


Troubleshooting

apt fails after I removed Python packages

You may have purged system python3 or a dependency apt needs. From a root shell, reinstall Ubuntu’s default stack:

bash
sudo apt update
sudo apt install --reinstall python3 python3-minimal

If apt itself errors before that, use Ubuntu recovery mode or a live ISO chroot.

python3.14 still appears after apt remove

Check for a source install under /usr/local:

bash
type -a python3.14

Remove /usr/local files from the altinstall section, or both Deadsnakes and /usr/local if you installed twice.

I only wanted to stop using 3.14 for one project

Delete or recreate the project venv; keep the system-wide python3.14 package if other projects use it.

sudo apt autoremove wants to remove unrelated packages

Read the proposed list before confirming. If essential libraries are marked for removal, cancel and remove only explicit python3.14* package names with apt remove --purge.


Summary

Uninstalling Python on Ubuntu means removing the extra interpreter you added—Deadsnakes packages, /usr/local altinstall files, a pyenv release, or a venv directory—not purging system python3. Match the removal steps to how you installed Python, verify python3 --version and sudo apt update afterward, and optionally drop the Deadsnakes PPA when you no longer need it.


References

Frequently Asked Questions

1. Is it safe to uninstall python3 on Ubuntu?

No. Do not remove the default python3, python3-minimal, or libpython3 packages Ubuntu ships. Removing them can break apt, cloud-init, and other system tools. Uninstall only the extra version you added, such as python3.14 from Deadsnakes or /usr/local from source altinstall.

2. How do I uninstall Python 3.14 installed from the Deadsnakes PPA?

Run sudo apt remove --purge python3.14 python3.14-venv python3.14-dev and any related python3.14-* packages, then sudo apt autoremove. Verify with command -v python3.14 and confirm python3 --version still works.

3. How do I remove Python installed with make altinstall on Ubuntu?

Delete the versioned files under /usr/local/bin (python3.14, pip3.14), /usr/local/lib/python3.14, /usr/local/include/python3.14, and matching man pages. Do not remove /usr/bin/python3 or the system libpython3 packages.

4. Does uninstalling Python delete my project code?

Removing an interpreter does not delete your .py source files. It does remove access through that binary until you reinstall. Delete project virtualenv directories separately with rm -rf if you no longer need them.

5. How do I know which Python install method I used?

Run which python3.14 or which python3.15. A path under /usr/bin usually means Deadsnakes or Ubuntu packages; /usr/local/bin usually means source altinstall; ~/.pyenv/shims means pyenv.

6. Should I remove the Deadsnakes PPA after uninstalling Python?

Optional. If you removed all Deadsnakes Python packages and will not install another version from that PPA, run sudo add-apt-repository --remove ppa:deadsnakes/ppa and sudo apt update.
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware.

  • Debian
  • Ubuntu
  • Linux
  • Red Hat Enterprise Linux