CentOS7默認安裝了python2.7.5,當須要使用python3的時候,能夠手動下載Python源碼後編譯安裝。
1.安裝python3.5可能使用的依賴
1 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
2.下載python
wget "https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz"
3.解壓下載好的壓縮包
tar -zxvf Python-3.5.0.tgz
4.配置編譯
1 sudo mkdir /usr/local/python3
2 sudo Python-3.5.0/configure --prefix=/usr/local/python3
3 sudo make
4 sudo make install
5.備份舊版本python,連接新版本python
在/usr/bin中有python、python二、python2.7三個文件依次指向後者
1 sudo mv python python.bak,
2 sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python
6.修改yum配置文件
sudo vi /usr/bin/yum
將第一行指定的python版本改成python2.7(#!/usr/bin/python 改成 #!/usr/bin/python2.7)python