问题
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:
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.
How will I make the system use python2.7 as its default python? Or if possible, how will I uninstall python2.6?
Thanks in advance!
回答1:
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.
回答2:
Uninstalling fedora-provided python 2.6 might break many packages that depend on it. I advise you against doing it.
Now, your problem is simply that $PATH
and similar variables ($MAN_PATH
etc.) are searched from left to right. You appended your new /opt/python27/bin
after standard locations like /usr/bin
. Reverse the order, and you will get /opt/python27/bin/python as a default python binary.
回答3:
First of all - never ever try to uninstall Python on RHEL/CentOS/Fedora. yum
is written in Python and there will be many problems with repairing the system.
If you want the system to use Python2.7 by default, find where the Python2.6 (use whereis python
or which python
commands) binary is located, backup it and replace with the binary of Python2.7
回答4:
Instead of uninstall older version, use specific version of python while using it
I changed symbolic link
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
And used
python -m pip install pip --upgrade
回答5:
Or you can simply use Yum feature of linux & run command yum remove python
it will delete python & related dependencies from the system
来源:https://stackoverflow.com/questions/10724471/how-to-uninstall-python2-6