【python】python版本升级2.6.6到2.7.3(CentOS release 6.2)
一、 升级python到2.7.3
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -zxvf Python-2.7.3.tgz
cd Python-2.7.3
mkdir /usr/local/python27
./configure --prefix=/usr/local/python27
make
make install
mv /usr/bin/python /usr/bin/python2.6
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
以上步骤完成后,输入python应该会显示2.7.3版本了
二、升级完python后,yum居然用不了了- -!需要如下修改
vim /usr/bin/yum
把#!/usr/bin/python改成 #!/usr/bin/python2.6 也就是让yum还是用老版本的python.
三、安装pip
1.先要安装setuptools
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python setup.py build
python setup.py install
2.安装pip
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
tar -zxvf pip-1.5.4.tar.gz
cd pip-1.5.4
python setup.py install
按上面的安装了pip后,pip install时出现了报错
pkg_resources.DistributionNotFound: pip==7.1.0
解决:
先安装distribute-0.6.10
wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.10.tar.gz
tar zxvf distribute-0.6.10.tar.gz
cd distribute-0.6.10
python setup.py install
再安装pip 7.1.0
easy_install pip==7.1.0