1. 安裝依賴環境
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
2. 下載Python3.7的安裝包
# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
3. 創建Python3的目錄
# mkdir /usr/local/python3
4. 解壓下載文件並切換目錄
# tar -zxvf Python-3.7.0.tgz
# cd Python-3.7.0
5. 執行
# ./configure
若出錯 可能因為gcc沒有安裝
yum -y install gcc
yum -y install gcc-c++
運行后會提醒
If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations
可以運行 ./configure --enable-optimizations 進行配置優化
# make && make install
6. 創建軟鏈接
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
7.測試命令 python3 和 pip3
# python3 -V
# pip3 -V