如何在 Ubuntu 16.04 上完全卸载 python 2.7.13

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44602191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 00:12:55  来源:igfitidea点击:

How to completely uninstall python 2.7.13 on Ubuntu 16.04

pythonpython-2.7ubuntuubuntu-16.04

提问by Lucas

I installed Python 2.7.13on Ubuntu 16.04according to this guide, and it became the default version as an alternative to the version 2.7.12. But, I wanted to completely remove Python 2.7.13and return back to the version 2.7.12as the default version since the pipcommand does not work with the following error.

我装Python 2.7.13Ubuntu 16.04根据本指南,并成为默认的版本作为替代version 2.7.12。但是,我想完全删除Python 2.7.13并返回到version 2.7.12默认版本,因为该pip命令对以下错误不起作用。

bash: /usr/local/bin/pip: /usr/bin/python: bad interpreter: No such file or directory

Could you please help me how to completely remove Python 2.7.13from Ubuntu 16.04? Otherwise, could you please suggest how to fix the above error?

你能帮我如何完全删除Python 2.7.13Ubuntu 16.04?否则,您能否建议如何解决上述错误?

回答by Subarata Talukder

caution : It is not recommended to remove the default Python from Ubuntu, it may cause GDM(Graphical Display Manager, that provide graphical login capabilities) failed.

注意:不建议从 Ubuntu 中删除默认的 Python,它可能会导致 GDM(提供图形登录功能的图形显示管理器)失败。

To completely uninstall Python2.x.x and everything depends on it. use this command:

要完全卸载 Python2.xx 一切都取决于它。使用这个命令:

sudo apt purge python2.x-minimal

As there are still a lot of packages that depend on Python2.x.x. So you should have a close look at the packages that apt wants to remove before you let it proceed.

由于仍然有很多包依赖于 Python2.xx 所以你应该仔细查看 apt 想要删除的包,然后再让它继续。

Thanks, I hope it will be helpful for you.

谢谢,希望对你有帮助。

回答by Sean

try following to see all instances of python

尝试按照以下步骤查看 python 的所有实例

whereis python
which python

Then remove all instances using:

然后使用以下方法删除所有实例:

sudo apt autoremove python

repeat sudo apt autoremove python(for all versions) that should do it, then install Anaconda and manage Pythons however you like if you need to reinstall it.

重复 sudo apt autoremove python(对于所有版本)应该这样做,然后安装 Anaconda 并管理 Pythons,如果你需要重新安装它,你喜欢。

回答by Benoit Mrx

How I do:

我怎样做:

# Remove python2
sudo apt purge -y python2.7-minimal

# You already have Python3 but 
# don't care about the version 
sudo ln -s /usr/bin/python3 /usr/bin/python

# Same for pip
sudo apt install -y python3-pip
sudo ln -s /usr/bin/pip3 /usr/bin/pip

# Confirm the new version of Python: 3
python --version

回答by tayfun K?l??

sudo apt purge python2.7-minimal