Python3.7與Python2.7在centos7下相容並存

安全劍客發表於2019-09-21

Python3.7與Python2.7在centos7下相容並存Python3.7與Python2.7在centos7下相容並存
1、下載python3.7

wget "https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz"

2、解壓下載好的壓縮包

tar -zxvf Python-3.7.0.tgz

3、配置編譯python3.7

mkdir /usr/local/python3
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make
make install

(make install的時候如果報如下錯:ModuleNotFoundError: No module named '_ctypes',是因為3.7版本需要新的包libffi-devel,使用如下 命令安裝即可: yum install libffi-devel -y ;然後再make install)

4、配置環境變數

修改 /etc/profile 檔案,在檔案末尾加上如下兩行程式碼

PATH=$PATH:/usr/local/python3/bin
export PATH

最後執行 命令 source /etc/profile 或執行點命令 ./profile 使其修改生效.

原文地址: https://www.linuxprobe.com/python-centos7-compatible.html

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31559985/viewspace-2657838/,如需轉載,請註明出處,否則將追究法律責任。

相關文章