
1.2.1 安装Python开发环境
Python主要的版本有Python 2.7和Python 3.x,因为2020年Python 2.7已经停止更新,所以本书选择使用比较广泛的Python 3.7.3,请读者确保计算机中有对应版本。打开Web浏览器(如百度、Google、360、火狐等),搜索Python官网,如图1.3所示。

图1.3 搜索Python官网
进入Python官方网站,下载并安装程序,如图1.4所示。

图1.4 Python官方网站
在导航栏中,选择Downloads菜单,进入Python下载页面,在下拉菜单中,选择Windows命令,如图1.5所示。

图1.5 Python下载页面
进入Windows下载界面,选择对应的要下载的Python安装包,并下载到本地,这里选择下载64位版本Python 3.7.3,如图1.6所示。

图1.6 下载Windows平台的Python安装包
双击下载到本地的安装包,进入安装界面,需要特别注意的是,要勾选“Add Python 3.7 to PATH”复选框,用于添加Python的安装路径到PATH环境变量。如果希望将Python安装到指定路径下,就选择“Customize installation”选项;如果选择“Install Now”选项,系统就会直接开始安装Python,并安装到默认路径下(建议安装到自己指定的目录),如图1.7所示。

图1.7 安装界面
此处将Python安装到C:\Python37路径下,选择“Customize installation”选项,进入可选功能界面,默认全部勾选,直接单击“Next”按钮,如图1.8所示。

图1.8 可选功能界面
在图1.9所示的界面中,左侧箭头指向的是系统默认的Python安装路径,若需要更改默认安装路径,则可单击右侧箭头所指的“Browse”按钮。

图1.9 安装路径的设置
由于不使用默认路径,因此只需把安装路径更改为指定的路径即可,其他选项保持默认设置,这里将安装路径设置为“C:\Python37”,如图1.10所示。

图1.10 更改安装路径
更改安装路径后,单击“Install”按钮开始安装,一般2~3分钟就可以安装完成,如图1.11所示。
安装完成后,进入如图1.12所示的安装成功界面,单击“Close”按钮,安装工作就完成了。
Python安装完成后,需要查看安装的Python是否能成功运行。单击“开始”菜单按钮,在搜索栏中输入“cmd”,如图1.13所示。

图1.11 安装进度

图1.12 安装成功界面

图1.13 在搜索栏中输入“cmd”
直接按Enter键,就进入命令提示符(终端)界面。在命令提示符下输入“python”(不要输入双引号),输入完成按Enter键,如果出现如图1.14所示的信息,则表示Python开发环境已经成功安装。

图1.14 测试Python开发环境1
或者在命令提示符(终端)界面中输入“python-V”命令,如果成功输出Python 3.7.3的版本号,则表示Python开发环境已经成功安装,如图1.15所示。

图1.15 测试Python开发环境2