python3X安装beautifulsoup&&BS64遇到的一些error

未经允许,不得擅自改动和转载

用beautifulsoup写的没错的小爬虫地址:

前言: Beautiful Soup 3 目前已经停止开发,推荐在现在的项目中使用Beautiful Soup 4,不过它已经被移植到BS4了,也就是说导入时我们需要 import bs4 。所以这里我们用的版本是 Beautiful Soup 4.3.2 (简称BS4),另外据说 BS4 对 Python3 的支持不够好,虽然我用的Python35,如果有小伙伴用的是 Python3 版本,可以考虑下载 BS3 版本。
自己搞网页数据爬取时,需要 from bs4 import BeautifulSoup,所以在py程序运行中遇到了一系列错误.......

错误一:ImportError: No module named 'bs4'

错误如下:

python3X安装beautifulsoup&&BS64遇到的一些error_第1张图片
ImportError: No module named 'bs4
  • 解决方法如下

Python如何安装模块:

1.下载BS4模块:

http://www.crummy.com/software/BeautifulSoup/bs4/download/4.3/beautifulsoup4-4.3.2.tar.gz

2.解压到Python安装目录下的根目录中:


python3X安装beautifulsoup&&BS64遇到的一些error_第2张图片
根目录

3.运行cmd,进入解压缩后的目录(如果Python默认安装在C盘下,打开cmd之后可以使用cd ...语句先返回根目录,再进入Python27\beautifulsoup4-4.3.2)

python3X安装beautifulsoup&&BS64遇到的一些error_第3张图片
mark

4.进入Python27\beautifulsoup4-4.3.2之后安装BS4模块:
执行: python setup.py install

python3X安装beautifulsoup&&BS64遇到的一些error_第4张图片
python setup.py install

可参考链接:http://www.cnblogs.com/victor5230/p/6397449.html


然而又出现错误:

错误二: ImportError: cannot import name 'HTMLParseError'

解决bs4在Python 3.5下出现“ImportError: cannot import name 'HTMLParseError'”错误

  • 解决方法如下:
    直接在cmd命令框中执行pip --upgrade beautifulsoup4
python3X安装beautifulsoup&&BS64遇到的一些error_第5张图片
pip --upgrade beautifulsoup4

可参考链接:http://blog.csdn.net/sinat_26599509/article/details/50609646


错误三:bs4.FeatureNotFound

又出现错误:如下
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

python3X安装beautifulsoup&&BS64遇到的一些error_第6张图片
bs4.FeatureNotFound

  • 解决方法:
    首先安装'pip install wheel'
    https://www.zhihu.com/question/49221958/answer/115712155
    python3X安装beautifulsoup&&BS64遇到的一些error_第7张图片
    pip install wheel

安装pip install lxml

python3X安装beautifulsoup&&BS64遇到的一些error_第8张图片
pip install lxml

可参考链接1: https://www.zhihu.com/question/49221958/answer/115712155
可参考链接2: http://study.163.com/forum/detail/1002230039.htm

竟然就好了!!!!!!!

你可能感兴趣的:(python3X安装beautifulsoup&&BS64遇到的一些error)