CentOS 7 安装 Python3.7.1

2018-11-03 16:47 CentOS 7 安装 Python3.7.1已关闭评论

1.下载

官网:https://www.python.org/ftp/python/

此处我们下载最新版Python3.7.1

命令:wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz

2.解压

image

 

命令:tar xvJf Python-3.7.1.tar.xz

命令:mv Python-3.7.1 /usr/local/python-3.7.1

命令:cd /usr/local/python-3.7.1/

3.安装

a.首先安装依赖包

命令:yum -y groupinstall "Development tools"

命令:yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel libffi-devel

命令:yum -y install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

b.配置编译参数

命令:./configure --prefix=/usr/local/bin/python-3.7.1

c.编译源码

命令:make

d.安装源码

命令:make install

e.出现下列信息,说明安装成功

Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

image

 

4.创建软连接

a.删除原有的软连接文件

命令:rm -rf /usr/bin/python

b.创建新连接

命令:ln -s /usr/local/bin/python-3.7.1/bin/python3 /usr/bin/python
命令:ln -s /usr/local/bin/python-3.7.1/bin/pip3 /usr/bin/pip3

image

 

5.修复yum

a.编辑yum文件

命令:vi /usr/bin/yum

将头文件#!/usr/bin/python改为#!/usr/bin/python2.7

image

到此安装Python3.7全部完成

版权声明:本文著作权归原作者所有,欢迎分享,谢谢支持!
转载请保留注明:CentOS 7 安装 Python3.7.1 | DPIP知识库
分类:Python 标签:

评论已关闭!