1. 程式人生 > >CentOS6.8升級Python2.6為Python2.7

CentOS6.8升級Python2.6為Python2.7

預設的Centos的Python版本為2.6,使用pip的時候經常提示Python2.6已過期,那麼還是升級到Python2.7吧。

1. 下載檔案並解壓

wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar -zxvf Python-2.7.13.tgz

2. 建立目錄

mkdir /usr/local/python2.7

3. 開始編譯安裝

./configure --prefix=/usr/local/python2.7
make && make install

4. 備份原來的python

mv /usr/bin/python /usr/bin/python_old

5. 重新做軟鏈

ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python2.7

6. 校驗

[[email protected] Python-2.7.13]# python
Python 2.7.13 (default, May 15 2017, 11:00:16) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.