cd / # 進入根目錄 wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz # 下載python3.7 tar -xzvf Python-3.7.0.tgz # 解壓到當前目錄 cd /Python-3.7.0 # 進入解壓文件 # 安裝依賴庫 yum -y install gcc* glien* yum -y install zlib zlib-devel yum -y install bzip2 bzip2-devel yum -y install ncurses ncurses-devel yum -y install readline readline-devel yum -y install openssl openssl-devel yum -y install openssl-static yum -y install xz lzma xz-devel yum -y install sqlite sqlite-devel yum -y install gdbm gdbm-devel yum -y install tk tk-devel yum -y install libffi libffi-devel ./configure --prefix=/usr/local/python3 # 指定安裝路徑 make # 編譯 make install # 安裝 ln -s /usr/local/python3/bin/python3 /usr/bin/python3 # 創建python3的軟連接 rm -rf python # 刪除系統自帶python連接 ln -s /usr/bin/python3 /usr/bin/python # 創建python的軟連接,此時鍵入python即進入python3.7的環境 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 # 創建pip3的軟連接 rm -rf pip ln -s /usr/bin/pip3 /usr/bin/pip # 此時python路徑已經由python2.7修改成python3.7了,因此yum沒法正常使用 vi /usr/libexec/urlgrabber-ext-down # 進入vim編輯器,鍵'i',進入insert模式,將第一行的路徑修改成python2.7,鍵'esc',':',鍵入'wq'保存退出 vi /usr/bin/yum # 進入vim編輯器,鍵'i',進入insert模式,將第一行的路徑修改成python2.7,鍵'esc',':',鍵入'wq'保存退出 # 至此,python3.7安裝完畢
注:安裝python3.7以上版本,openssl版本須要在1.0.2以上python