Linux入门教程:CentOS 7 安装 Python 3.7, CentOS 的第

简介: Python 3.7 稳定版已经发布,Python 3.7 具有很多新特性,新用户推荐使用 Python 3.7,本文介绍如何在 CentOS7 系统上安装 Python 3.7,因为 CentOS 7 系统自带的 Python 版本是 Python 2.7。
+关注继续查看

Python 3.7 稳定版已经发布,Python 3.7 具有很多新特性,新用户推荐使用 Python 3.7,本文介绍如何在 CentOS7 系统上安装 Python 3.7,因为 CentOS 7 系统自带的 Python 版本是 Python 2.7。

CentOS 的第三方软件源中(如:IUS,SCL,EPEL)还没有 Python 3.7 的 RPM 软件包,本文先只介绍使用源码方式安装 Python 3.7。

CentOS 7 使用源文件安装 Python 3.7

1)安装依赖包

因为使用源码方式在 CentOS 7 系统中安装 Python 3.7,所以必须安装 GCC 编译器和 make 编译工具,这些软件包包含在 “Development tools” 软件组中,可以直接安装 “Development tools” 软件组:

sudo yum groupinstall "Development tools"

因为 Python 3.7 源文件使用 zlib 格式打包,所以需要安装 zlib 软件包;Python 3.7 编译安装时需要使用 zlib 的头文件和链接库,所以需要安装 zlib 的头文件和链接库 zlib-devel 软件包:

sudo yum -y install zlib zlib-devel

Python 3 有个内置模块 ctypes,它是 Python 3 的外部函数库(Foreign function library),它需要使用系统外部函数库(libffi)的头文件和链接库,所以需要安装外部函数库(libffi)头文件和链接库 libffi-devel 软件包:

sudo yum -y install libffi-devel

2)运行如下命令配置、编译、安装 Python 3.7

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xJf Python-3.7.0.tar.xz
cd Python-3.7.0
sudo ./configure
sudo make
sudo make install

如果在编译安装时提示 zipimport.ZipImportError: can’t decompress data; zlib not available 错误,请查看关于 zlib 的解决方法。

如果在编译安装时提示 ModuleNotFoundError: No module named ‘_ctypes’ 错误,请查看关于 ctypes 的解决方法。

3)安装完成后,Python 3.7 安装在了/usr/local文件夹中,可运行文件/usr/local/bin,库文件/usr/local/lib。因为 /usr/local/bin 在 Shell 路径中,所以可以直接在 Shell 中输入如下命令 python3 运行 Python 3.7 解释器。
原文地址

目录
相关文章
|
2天前
|
Ubuntu Linux
debian/rehhat/linux/centos/ubuntu 安装IDEA
debian/rehhat/linux/centos/ubuntu 安装IDEA
33 0
|
4天前
|
安全 网络协议 Linux
|
4天前
|
缓存 运维 Linux
Linux(CentOS)运维脚本工具集合
Linux(CentOS)运维脚本工具集合
|
4天前
|
Linux 测试技术 网络安全
|
19天前
|
Linux C语言
实验:CentOS 7 编译安装最新版内核 Linux Kernel 6.5.2
CentOS 7 编译安装最新版内核 Linux Kernel 6.5.2
131 0
|
28天前
|
Linux
linux中centos,用rpm,yum,编译分别安装软件具体步骤
linux中centos,用rpm,yum,编译分别安装软件具体步骤
|
28天前
|
缓存 Linux
linux中centos安装软件一般的步骤
linux中centos安装软件一般的步骤
|
1月前
|
网络协议 Linux 网络安全
无公网IP,SSH远程连接Linux CentOS服务器【内网穿透】
本次教程我们来实现如何在外公网环境下,SSH远程连接家里/公司的Linux CentOS服务器,无需公网IP,也不需要设置路由器。
58 1
|
1月前
|
存储 网络协议 Linux
Linux/centos上如何配置管理NFS服务器?
Linux/centos上如何配置管理NFS服务器?
45 0
相关产品
云迁移中心
推荐文章
更多