CentOS release 6.6 (Final) 安装升级Python2.7.7 Python2.7.9 Python3.4.3
1、查看当前系统中的python版本
#python --version 或 python -V
Python 2.6.6
2、检查CentOS版本
#cat /etc/redhat-release
3、安装所有的开发工具包
#yum groupinstall "Development tools" -y
4、安装其它的必需包
#yum install zlib-devel bzip2-devel openssl-devel ncurses-devel -y
5、下载、编译和安装Python2.7.7
cd /opt
wget https://www.python.org/ftp/python/2.7.7/Python-2.7.7.tgz
tar zxvf Python-2.7.7.tgz
cd Python-2.7.7
./configure
make install
5、下载、编译和安装Python3.4.3
cd /opt
wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
tar zxvf Python-3.4.3.tgz
cd Python-3.4.3
./configure
make install
6、查看Python版本。
用以下命令查看Python2.7是否已安装
#python2.7 --version
Python 2.7.7
用以下命令查看Python3.4是否已安装
#python3.4 --version
Python 3.4.3
7、更新系统默认Python和python-config版本(可选)
没必要的话最好不进行这项操作(可能会产生关联错误),建议使用python2 或者python3 代替。
先查找python的位置
#whereis python
python: /usr/bin/python2.6-config /usr/bin/python /usr/bin/python2.6 /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python3.4m
/usr/local/bin/python3.4-config /usr/local/bin/python3.4 /usr/local/bin/python3.4m-config /usr/local/lib/python3.4 /usr/include/python2.6
/usr/share/man/man1/python.1.gz
cd /usr/bin
rm python
rm python-config
ln -s /usr/local/bin/python3.4 /usr/bin/python //创建一个软连接
ln -s /usr/local/bin/python3.4m-config /usr/bin/python-config //创建一个软连接
#python --version
Python 3.4.3
reboot
8、安装和配置发行包(可选)
cd /opt
wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.27.tar.gz
tar xf distribute-0.6.27.tar.gz
cd distribute-0.6.27
python2.7 setup.py install
完成
(责任编辑:IT) |