首页 > 代码库 > CentOS安装,更新Python

CentOS安装,更新Python

1、查看当前Python版本

python -V

2、查看当前CentOS版本

cat /etc/redhat-release

3、安装所有的开发工具包

yum groupinstall "Development tools"

4、安装其他必须包

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel

5、下载编译安装Python(2.7.6为例,全部版本)

cd /opt
wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar xf Python-2.7.6.tgz
cd Python-2.7.6
./configure
make install

6、更新python命令对应版本

cd /usr/bin
ll |grep python
rm -rf python
ln -s /usr/local/bin/python2.7 ./python

7、检查Python最终版本

python -V

返回应为(例):Python 2.7.6rc1