zoukankan      html  css  js  c++  java
  • from bs4 import BeautifulSoup 报错

    导入BeautifulSoup,出现下面错误(两种):

    第一种错误:

    Python 2.7.14 (default, Sep 17 2017, 18:50:44)
    [GCC 7.2.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from bs4 import BeautifulSoup
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/lib/python2.7/dist-packages/bs4/__init__.py", line 30, in <module>
    from .builder import builder_registry, ParserRejectedMarkup
    File "/usr/local/lib/python2.7/dist-packages/bs4/builder/__init__.py", line 311, in <module>
    from . import _html5lib
    File "/usr/local/lib/python2.7/dist-packages/bs4/builder/_html5lib.py", line 57, in <module>
    class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
    AttributeError: 'module' object has no attribute '_base'
    >>>

    百度半天,都是说bs4写错的,还好看到个大佬解决了问题:http://blog.csdn.net/codechelle/article/details/56292200

    解决方法:就如博客大佬说的,改个名字,将 base.py 改为 _base.py,将 base.pyc 改为 _base.pyc 即可。

                      路径一般是一样的,照抄即可。

    第二种错误:

    然后发现:文件名错了,不能是bs4,所以改了下文件名,发现还是报错:

    但发现有个运行缓存文件没改过来,继而删除,搞定

  • 相关阅读:
    HTML标签大全
    PHP实现QQ第三方登录代码
    php链接access并查询列出
    php连接Access数据库
    获取文件信息
    动态网页转伪静态
    asp读取指定目录下的文件名
    如何设置VBA代码的密码?如何取消VBA代码的密码?
    ol序号并在序号加背景色
    免费ASP空间
  • 原文地址:https://www.cnblogs.com/4wheel/p/8251465.html
Copyright © 2011-2022 走看看