【发布时间】:2020-06-09 16:08:32
【问题描述】:
在我预装了 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
但是,当我通过终端(python -V)检查系统使用的python版本时,它仍然显示python 2.6。
如何让系统使用python2.7作为默认python? 或者如果可能的话,我将如何卸载python2.6?
提前致谢!
【问题讨论】:
-
尝试在 linux 机器上删除系统 python 通常是个坏主意。只需将 /opt 放在 PATH 中的 /usr/bin 之前,您就可以自己使用 2.7 而不会弄乱任何东西。