
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
1.2 安装Python
1.2.1 源码包安装方式
如果是Windows版本,则只要按照向导操作即可。下面主要说明如何在CentOS 7系统中安装Python 3.7.2。
安装依赖的软件包:

注意:请将上述软件包安装完整。虽然如果没有把列出的软件包全部安装上也能运行,但是在后面章节中编写代码时,将会不支持某些模块。
编译并安装:

注意:CentOS系统中有大量的程序是采用Python 2编写的。所以不要用Python 3把Python 2覆盖掉。两个版本的Python代码并不完全兼容,如果Python 3覆盖掉了Python 2,则系统中将有大量的程序无法正确地运行。
1.2.2 二进制rpm包安装方式
CentOS光盘镜像中并不存在Python 3的rpm包,可以通过国内开源镜像的yum源进行安装。本例采用网易镜像进行演示。首先访问网易开源镜像站,如图1-2所示。

图1-2
单击【centos使用帮助】链接后,在【CentOS7】链接上右击,选择【复制链接地址】菜单项,如图1-3所示。

图1-3
下载网易镜像站点配置文件:

安装Python 3:

注意:两种安装方式二选一。编写代码时并无任何区别。本书采用第一种方法安装的Python进行讲解。