centOS7.6安装python3.7.0

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以上

转载于:https://www.cnblogs.com/cooper-wang/p/10690368.html

你可能感兴趣的:(centOS7.6安装python3.7.0)