CentOS7原生已有拍森2.7,為了某些原因需要升級並保留舊版。
此時,就出現了升級新版、保留舊版,需可切換的需求惹= =
將開發環境、測試環境、正式環境盡可能獨立,是一個好習慣,也方便日後查找問題。
下載python3
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
備份
mv python python.bak
安裝python3
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar -xvJf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure prefix=/usr/local/python3
make && make install
到執行目錄下/usr/bin
設置連結
ln -s /usr/local/python3/bin/python3 /usr/bin/python
執行
python2 -V
確認預設值並切換看看^^
參考來源
https://hk.saowen.com/a/4b19bd3858389780902c855ad848f8e8fde37fc3dc2d2ad16601f4f903fac717
https://www.jianshu.com/p/1babc657914c
http://35.194.140.171/wordpress/?p=444
http://www.tk4479.net/gcangle/article/details/50098151
http://www.itboth.com/d/JF7FBb/linux-python-ambari