安裝pyhton3.7 的依賴包
sudo yum -y groupinstall "Development tools"
sudo 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
下載python3.7的“源碼”:
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
解壓並編譯安裝:
tar -xJvf Python-3.7.0.tar.xz
cd Python-3.7.0
./configure --prefix=/usr/local/python3 --enable-shared
make && make install
執行完make&&make install之后,可能會出現這種報錯:
“ModuleNotFound:No module named '_ctypes'”
這里需要執行:
yum install libffi-devel -y
配置環境變量:
1.cd /usr/local/python3/bin/
2.vim python3.conf
#把這條加進去保存
3./usr/python/lib
#啟動配置
4.ldconfig
"""
cd /etc/ld.so.conf.d
vim python3.conf
#添加python庫路徑,因為我們開始把python的編譯后的路徑設置在/usr/python,所以python庫的路徑為/usr/python/lib
#按i輸入,輸入成功后按Esc建,輸入:wq保存退出
/usr/python/lib
""""
#新建軟鏈接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
將編譯目錄下的libpython3.7m.so.1.0文件復制到
/usr/lib64/libpython3.7m.so.1.0
注:我不太清楚具體放到哪個文件下,沒有試驗,所以把lib文件全都放了一下,有時間可以具體確認
切換python
$ alias python='/usr/bin/python3'
$ python --version
Python 3.4.3 # 版本已經改變
yum install vim
