Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall Python2.6

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!

like image 803
jaysonpryde Avatar asked May 23 '12 16:05

jaysonpryde


3 Answers

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.

like image 172
Ramashish Baranwal Avatar answered Oct 08 '22 22:10

Ramashish Baranwal


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.

like image 33
Tadeusz A. Kadłubowski Avatar answered Oct 08 '22 21:10

Tadeusz A. Kadłubowski


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

like image 2
mega.venik Avatar answered Oct 08 '22 20:10

mega.venik