分类: Python/Ruby
2013-10-11 14:17:55
Install python-2.7 on CentOS-5.6
Reference:
http://uniccus0223.blogspot.jp/2012/04/install-python-27-on-centos-56.html
yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel make
cd /var/tmp
wget
tar xfz sqlite-amalgamation-3.7.3.tar.gz
cd sqlite-3.7.3/
./configure
make
make install
cd /var/tmp
wget
tar xvfz Python-2.7.1.tgz
cd Python-2.7.1
./configure --prefix=/opt/python2.7.1 --with-threads --enable-shared
make
make install
touch /etc/ld.so.conf.d/opt-python2.7.1.conf
echo "/opt/python2.7.1/lib/" >> /etc/ld.so.conf.d/opt-python2.7.1.conf
ldconfig
ln -sf /opt/python2.7.1/bin/python /usr/bin/python2.7
cd /var/tmp
wget
sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7.1
ln -sf /opt/python2.7.1/bin/easy_install /usr/bin/easy_install
/opt/python2.7.1/bin/easy_install pip
ln -sf /opt/python2.7.1/bin/pip /usr/bin/pip
pip install virtualenv
ln -sf /opt/python2.7.1/bin/virtualenv /usr/bin/virtualenv
mv /usr/bin/python /usr/bin/python-backup
ln -s /usr/bin/python2.7 /usr/bin/python
easy_install unittest2
easy_install nose
easy_install unittest-xml-reporting
升级安装好以后yum会无法使用,因为yum使用的是2.4版本的,所以要修改yum的配置文件以便能够识别2.4版本下的python
vim /usr/bin/yum
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.4
就可以继续使用yum了