Как удалить python ubuntu
Перейти к содержимому

Как удалить python ubuntu

  • автор:

Uninstall Python in Ubuntu

This article demonstrates how to delete or uninstall Python from Ubuntu.

Please enable JavaScript

Check if Python Installed in Your System

Open the Terminal using Ctrl+Alt+T .
After opening the terminal, check whether your system has python installed or not by using the command python3 —version .
If the command replies with the specific version of python, then leave it because you have already installed python on your pc/desktop.
If the command replies with Command not found , then to install python, write the command sudo apt install python3 .

There are many ways for its uninstallation depending upon a user’s needs. Different commands in the terminal do different tasks.

If there is only a need to delete specific dependencies related to a specific module of python or if there is a need to delete all the dependencies or to remove the Python3 package.

Depending upon the specific needs and requirements, the user can run the commands in the terminal for specific actions.

Ways to Remove/Uninstall Python in Ubuntu

Uninstall/Delete a Specific Version

Suppose a user wants to delete a specific version of Python installed on the Ubuntu machine. Run the below command and enter your user password. The version of Python will be removed from the machine.

Remove Only the python3 Package

If a user wants to remove the specific package of Python, i.e., python 3.5 , run the below command and select and remove the python3 packages.

Remove Packages With Their Dependencies

Suppose you want to remove a package and all the dependencies related to that package, run the below-mentioned command, enter your ubuntu password, and the package will be removed along with its dependencies.

Remove Settings, Configs, Datafiles Collectively

Suppose a user wants to remove all the configurations and settings or data files related to a python package. In that case, he should mention the below command in the terminal and enter the machine’s password to continue.

Remove Configs, Data Files, and Dependencies of python3.5

If a user wants to collectively remove any Python package’s configuration, files, and dependencies, then the user must use the below command.

Command (for any version):

Command (for python3.5):

Hello! I am Salman Bin Mehmood(Baum), a software developer and I help organizations, address complex problems. My expertise lies within back-end, data science and machine learning. I am a lifelong learner, currently working on metaverse, and enrolled in a course building an AI application with python. I love solving problems and developing bug-free software for people. I write content related to python and hot Technologies.

How to make a complete removal of Python 3.9 in Ubuntu 16.04?

I installed Python 3.9 on my Ubuntu 16.04 LTS system, in addition to the default 2.7 and 3.5 that come with the system. I can call it perfectly by typing python3.9, and also use pip3.9 commands.

I want to remove it form the system, for reinstalling it, or even and earlier version of python instead.

I tried already sudo apt-get remove python3.9 , sudo apt-get autoremove python3.9 , sudo apt-get purge python3.9 , sudo apt-get remove —purge python3.9 and sudo apt-get autoremove —purge python3.9 . None seems to make effect.

Ubuntu, how do you remove all Python 3 but not 2

I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place:

iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7

Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7.

So the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?

Remi Guan's user avatar

6 Answers 6

Removing Python 3 was the worst thing I did since I recently moved to the world of Linux. It removed Firefox, my launcher and, as I read while trying to fix my problem, it may also remove your desktop and terminal! Finally fixed after a long daytime nightmare. Just don’t remove Python 3. Keep it there!

If that happens to you, here is the fix:

Hazem's user avatar

EDIT: As pointed out in recent comments, this solution may BREAK your system.

You most likely don’t want to remove python3.

Please refer to the other answers for possible solutions.

Outdated answer (not recommended)

Germain's user avatar

So I worked out at the end that you cannot uninstall 3.4 as it is default on Ubuntu.

All I did was simply remove Jupyter and then alias python=python2.7 and install all packages on Python 2.7 again.

Arguably, I can install virtualenv but me and my colleagues are only using 2.7. I am just going to be lazy in this case 🙂

First of all, don’t try the following command as suggested by Germain above.

In Ubuntu, many software depends upon Python3 so if you will execute this command it will remove all of them as it happened with me. I found following answer useful to recover it.

If you want to use different python versions for different projects then create virtual environments it will be very useful. refer to the following link to create virtual environments.

Creating Virtual Environment also helps in using Tensorflow and Keras in Jupyter Notebook.

uninstall Python installed by compiling source?

I installed Python 2.7.9 on Ubuntu 14.04 by compiling its source, by .configre , make , and make altinstall . make altinstall is because I don’t want to overwrite the default Python 2.7.6. My self installed 2.7.9 is in /usr/local/bin/python2.7 and many other files in other directories under /usr/local . From README in the source installation package:

On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (—prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version.

All files and directories installed using «make altinstall» contain the major and minor version and can thus live side-by-side. «make install» also creates $/bin/python which refers to $/bin/pythonX.Y.

If you intend to install multiple versions using the same prefix you must decide which version (if any) is your «primary» version. Install that version using «make install». Install all other versions using «make altinstall».

For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute «make install» in your 2.6 build directory and «make altinstall» in the others.

Now I want to uninstall my self installed 2.7.9.

Fortunately I still have the source code, but unfortunately, the Makefile doesn’t have uninstall section

Then I tried another way: first create a deb from the source and compilation, install the deb (hopefully overwriting the installed files from make altinstall ), and then uninstall the deb.

But when I create the deb file by checkinstall , I am not sure if and how I should do differently for make altinstall from for make install . What I tried is:

I wonder how I can create a deb so that installing the deb will duplicate the installation process of make altinstall ?

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *