Linux 如何卸载Python2.6

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10724471/
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-06 06:27:05  来源:igfitidea点击:

How to uninstall Python2.6

pythonlinuxfedora11

提问by jaysonpryde

On my Fedora11 machine which has python2.6 pre-installed on it, I was able to successfully install python 2.7 using the following steps:

在预装了 python2.6 的 Fedora11 机器上,我能够使用以下步骤成功安装 python 2.7:

wget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2
tar -xvjf Python-2.7.tar.bz2
cd Python*
./configure --prefix=/opt/python27
make
make install
vi ~/.bash_profile
## replaced PATH=$PATH:$HOME/bin
## with PATH=$PATH:$HOME/bin:/opt/python27/bin

## reload .bash_profile
source ~/.bash_profile
echo "/opt/python27/lib" > /etc/ld.so.conf.d/python27.conf
ldconfig

However, when I checked the python version the system uses via terminal (python -V), it still shows python 2.6.

但是,当我通过终端(python -V)检查系统使用的python版本时,它仍然显示python 2.6。

How will I make the system use python2.7 as its default python? Or if possible, how will I uninstall python2.6?

如何让系统使用 python2.7 作为默认 python?或者如果可能的话,我将如何卸载 python2.6?

Thanks in advance!

提前致谢!

回答by mega.venik

First of all - never ever try to uninstall Python on RHEL/CentOS/Fedora. yumis written in Python and there will be many problems with repairing the system.

首先 - 永远不要尝试在 RHEL/CentOS/Fedora 上卸载 Python。yum是用python写的,修复系统会有很多问题。

If you want the system to use Python2.7 by default, find where the Python2.6 (use whereis pythonor which pythoncommands) binary is located, backup it and replace with the binary of Python2.7

如果想让系统默认使用Python2.7,找到Python2.6(use whereis pythonor which pythoncommands)二进制文件所在的位置,备份并替换为Python2.7的二进制文件

回答by Tadeusz A. Kad?ubowski

Uninstalling fedora-provided python 2.6 might break many packages that depend on it. I advise you against doing it.

卸载 fedora 提供的 python 2.6 可能会破坏许多依赖它的软件包。我劝你不要这样做。

Now, your problem is simply that $PATHand similar variables ($MAN_PATHetc.) are searched from left to right. You appended your new /opt/python27/binafterstandard locations like /usr/bin. Reverse the order, and you will get /opt/python27/bin/python as a default python binary.

现在,您的问题很简单,从左到右搜索$PATH类似的变量($MAN_PATH等)。您/opt/python27/bin标准位置(如/usr/bin. 颠倒顺序,您将获得 /opt/python27/bin/python 作为默认的 Python 二进制文件。

回答by Ramashish Baranwal

Uninstalling the system Python is a bad idea. There are many other packages and softwares that depend on it. It'll be better that you use python2.7 by either modifying the $PATH or creating an alias e.g. python2.7 that points to the python that you installed in /opt dir.

卸载系统 Python 是一个坏主意。还有许多其他软件包和软件依赖于它。最好通过修改 $PATH 或创建别名(例如 python2.7 指向安装在 /opt 目录中的 python)来使用 python2.7。

回答by Deepak Pawaskar

Or you can simply use Yum feature of linux & run command yum remove pythonit will delete python & related dependencies from the system

或者你可以简单地使用 linux & run 命令的 Yum 功能,yum remove python它会从系统中删除 python 和相关的依赖项

回答by user3535208

Instead of uninstall older version, use specific version of python while using it

使用时不要卸载旧版本,而是使用特定版本的python

I changed symbolic link

我改变了符号链接

ln -s /usr/local/bin/python2.7 /usr/local/bin/python

And used

并使用

python -m pip install pip --upgrade