
1.1 Python SDK安装
Python是跨平台语言,可以运行在Windows、Mac及Linux/UNIX系统上,因此编写的代码在平台上没有运行的限制。目前,Python有Python 2和Python 3两个版本,不幸的是两个版本很多地方不兼容。由于Python 2即将停止支持,而越来越多的库已经支持Python 3,况且Python 3也提供了很多Python 2没有的新功能,因此本书使用Python 3搭建环境。
1.1.1 在Windows上安装Python
首先从Python官网(https://www.python.org/downloads/)下载安装包,本书使用的是3.6.3版本,读者也可以下载更新的版本。下载后文件名为python-3.6.3-amd64.exe,双击进行安装。
(1)在安装时先勾选Add Python 3.6 to PATH复选框,再选择Customize installation选项,如图1.1所示。

图1.1 Python 3.6安装首页
(2)务必选中pip复选框,单击Next按钮进行安装,如图1.2所示。

图1.2 pip选项
(3)选择安装路径,默认安装即可。打开命令提示窗口,输入python,若出现Python版本号,则进入Python交互页面“>>>”,说明安装成功,如图1.3所示。

图1.3 Python 3.6安装检测
1.1.2 在Ubuntu上安装Python
本书Linux发行版使用的是Ubuntu 18.04,读者也可选择其他Ubuntu版本或者其他Linux发行版。Ubuntu 18.04已经安装好了Python 3,版本为3.6.5。打开终端,输入python3命令,如图1.4所示。

图1.4 Python 3.6安装检测
这里我们需要手动安装pip,使用命令sudo apt install python3-pip进行安装,安装完成之后,运行pip3,结果如图1.5所示。

图1.5 pip安装检测