centos6 更新升级python

由于最近要做些python的开发工作,故记录下在centos环境下 python的默认版本升级!


#更新python
yum install openssl openssl-devel -y
yum install ncurses ncurses-devel -y
yum install zlib zlib-devel  python-devel -y
yum groupinstall "development tools" -y
wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar xvzf Python-2.7.11.tgz
cd Python-2.7.11
./configure --prefix=/usr/local
make --jobs=`grep processor /proc/cpuinfo | wc -l`
make install



## 将python头文件拷贝到标准目录,以避免编译其他项目时,找不到所需的头文件
cd /usr/local/include/python2.7
cp -a ./* /usr/local/include/

## 备份旧版本的python,并符号链接新版本的python
cd /usr/bin
mv python python-bak
ln -s /usr/local/bin/python ./

## 修改yum脚本,使其指向旧版本的python,已避免其无法运行
sed -i 's/python/python2.6/' /usr/bin/yum

#安装pip easy_install 
setuptools模块安装
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz --no-check-certificate
tar xvzf setuptools-7.0.tar.gz
cd setuptools-7.0
python setup.py build
python setup.py install


wget https://pypi.python.org/packages/source/p/pip/pip-8.1.1.tar.gz
tar xvzf  pip-8.1.1.tar.gz
cd pip-8.1.1
python setup.py build
python setup.py install

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.