环境安装 =============================================== 这一章节介绍一下怎么安装python相关环境 ------------------- 安装Python ----------------------------------------------------------------------------------------------------- 打开 python官网下载地址 https://www.python.org/downloads/ ,在下方找到Python 3.7.0,选择对应的系统和版本点击下载 打开,选择跟自己操作系统匹配的安装包,然后下载,如windows 64,则选择 **Windows x86-64 MSI installer**,安装完成后,打开一个命令行窗口,然后输入python,如果出现python的提示符,说明安装成功。 .. warning:: Windows安装过程中需勾选 **Add python.exe to Path** ,如下图所示: .. figure:: /_static/python/install/img1.png :width: 12.0cm ------------------- pip简介 ----------------------------------------------------------------- pip是python自带的包管理器,安装完python后,即可拥有,pip常用命令如下:: >>> pip install <包名> # 安装python包 >>> pip install -U <包名> # 更新包 >>> pip uninstall <包名> # 删除python包 >>> pip list # 查看安装的包 pip下载python包是从https://pypi.python.org/下载的,pypi服务器在国外,因此国内访问可能速度会比较慢,但使用时可以指定国内源,也就是从国内的镜像服务器下载,如使用清华的源:: >>> pip install flask -i https://pypi.tuna.tsinghua.edu.cn/simple 除了在命令行指定源外,也可以在本地配置,使用方法可以在网络上搜索一下 其他常用源: 清华:https://pypi.tuna.tsinghua.edu.cn/simple 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:http://pypi.hustunique.com/ 山东理工大学:http://pypi.sdutlinux.org/ 豆瓣:http://pypi.douban.com/simple/ 安装ipython -------------------------------------------------------------------------- ipython是一个python的交互命令行工具,比python自带的增强了代码高亮,自动完成,代码提示功能,非常适合初学者 **Windows** 下载安装 `pyreadline `_,而后执行:: >>> pip install ipython >>> ipython Python 2.7.13 (default, Apr 26 2017, 20:42:49) Type "copyright", "credits" or "license" for more information. IPython 5.1.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: **Linux&Unix** 执行:: >>> pip install ipython >>> ipython Python 2.7.13 (default, Apr 26 2017, 20:42:49) Type "copyright", "credits" or "license" for more information. IPython 5.1.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: 安装pycharm ------------------------------------------------------------ pycharm是个人认为目前对初学者最友好的IDE,初学者下载社区版(免费的)就可以了,下载地址: `链接 `_,选择Community,然后下载安装。