python 安装模块requests、bs4、html5lib、 lxml、matplotlib

前言:最近学习python,想尝试下实现抓取网页的文本,并实现词频统计的功能。实现该功能需要安装的模块,分别是  requests、bs4html5lib、 lxml、matplotlib
背景:已经安装了python3.6,设置好环境变量,安装了pip模块
操作界面:cmd界面

  • 安装模块requests
S1 输入 pip install requests

  • 安装模板 bs4
S1 查看python的目录下是否有 Scripts->easy_install 文件,若有,进入S2;
S2 进入cmd命令界面
S3 输入 easy_install.exe pip ,回车 
S4 安装成功后,继续输入 pip install beautifulsoup4 回车
python 安装模块requests、bs4、html5lib、 lxml、matplotlib

  • 装模块html5lib
问题:使用html5lib时,出现错误代码
 bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
原因:
bs4需要调用python自带的html解析器,自己安装的python3.6是没有html解释器的,所以会报错。在python3也装一个html解析器就好了。

S1 输入 pip install html5lib,回车
python 安装模块requests、bs4、html5lib、 lxml、matplotlib

  •  安装 lxml模块
S1 输入 pip install lxml
python 安装模块requests、bs4、html5lib、 lxml、matplotlib
  • 安装matplotlib模块
S1 输入 python -m pip install -U pip setuptools
S2 输入 python -m pip install matplotlib
python 安装模块requests、bs4、html5lib、 lxml、matplotlib