Python的安装

1.下载程序
首先访问去下载最新的版本 。
根据需要下载或者,同时注意自己的操作系统版本是64位还是32位,选择符合自己的
这里介绍 的安装
2.安装下载包,一路next 。
3.配置环境变量
右键计算机-->属性-->高级系统设置-->环境变量-->
在系统变量里面找到Path, 然后将 安装路径加入进去,注意里面的分号是英文格式的 ‘;’

Python的安装

文章插图
打开cmd 终端参照下面,如果能显示 版本,就可以工作了
C:\>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> a = 'hello world'>>> print ahello world>>>
4. 其他配置
虽然至此 能够工作了,但是还有一些其他的内容需要配置
我们使用 的时候,难免要使用到一些第三方库,或者一些架构,因此需要先把工具准备好
4.1 pip 工具
首先 同样的配置环境变量
将 目录下的 也加到环境变量中去
Python的安装

文章插图
C:\\
然后在命令行下执行pip
但是很遗憾,系统提示如下:
C:\Python27>pip'pip' 不是内部或外部命令,也不是可运行的程序或批处理文件 。
为什么呢,因为刚才的终端没有关闭,需要我们重新打开一下,然后我们尝试安装一下 bs4
C:\Python27\Scripts>pip install bs4Collecting bs4Using cached bs4-0.0.1.tar.gzCollecting beautifulsoup4 (from bs4)Using cached beautifulsoup4-4.5.3-py2-none-any.whlInstalling collected packages: beautifulsoup4, bs4Running setup.py install for bs4Successfully installed beautifulsoup4-4.5.3 bs4-0.0.1You are using pip version 7.1.2, however version 9.0.1 is available.You should consider upgrading via the 'python -m pip install --upgrade pip' command.
系统提示我们,pip 的版本太低了,那我们升级一下pip 的版本
python -m pip install --upgrade pip
接着执行
pip install bs4
实验一下是否安装成功
C:\Python27\Scripts>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import bs4>>>
没有报错,那就OK了
4.2 利用 安装 lxml
C:\Python27\Scripts>easy_install-2.7.exe lxmlSearching for lxmlReading https://pypi.python.org/simple/lxml/Best match: lxml 3.7.2Downloading https://pypi.python.org/packages/66/45/f11fc376f784c6f2e77ffc7a9d02374ff3ceb07ede8c56f918939409577c/lxml-3.7.2.tar.gz#md5=8dcf8d6c692Processing lxml-3.7.2.tar.gzWriting c:\windows\temp\easy_install-iudefp\lxml-3.7.2\setup.cfgRunning lxml-3.7.2\setup.py -q bdist_egg --dist-dir c:\windows\temp\easy_install-iudefp\lxml-3.7.2\egg-dist-tmp-4pweyfBuilding lxml version 3.7.2.Building without Cython.ERROR: 'xslt-config' 不是内部或外部命令,也不是可运行的程序或批处理文件 。** make sure the development packages of libxml2 and libxslt are installed **Using build configuration of libxslterror: Setup script exited with error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
报错提示我们需要安装C++ 9.0
点击这里下载
安装下载好的 .msi 一路next 就好