一、安裝依賴包 python
1)首先安裝gcc編譯器,gcc有些系統版本已經默認安裝,經過 gcc --version 查看,沒安裝的先安裝gcc,yum -y install gcclinux
2)安裝其它依賴包,(注:不要缺乏,不然有可能安裝python出錯,python3.7.0如下的版本可不裝 libffi-devel )sql
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-develide
2)下載測試
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
3)、解壓Python-3.7.0.tgzorm
tar -zxvf Python-3.7.0.tgzsqlite
四、創建一個空文件夾,用於存放python3程序 ip
mkdir /usr/local/python3 ssl
五、執行配置文件,編譯,編譯安裝 get
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
安裝完成沒有提示錯誤便安裝成功了
七、創建軟鏈接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
八、測試一下python3是否能夠用
複製代碼
[root@instance-rupxcbi1 Python-3.7.0]# python3
Python 3.7.0 (default, Oct 28 2019, 09:09:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
print("hello word")
hello word
exit()能夠看到python3.7.0能夠正常使用