BeautifulSoup 错误 Python 3.4.3

BeautifulSoup error Python 3.4.3

Python 3.4.3(64 位)Windows 7 我的 bs4/requests 运行 正常,然后我从我的程序 bs1.py 中得到了所有这些东西:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Python34\myprograms\bs1.py", line 1, in <module>
    import requests, bs4
  File "C:\Python34\lib\site-packages\requests\__init__.py", line 58, in <module>
    from . import utils
  File "C:\Python34\lib\site-packages\requests\utils.py", line 12, in <module>
    import cgi
  File "C:\Python34\lib\cgi.py", line 42, in <module>
    import html
  File "C:\Python34\myprograms\html.py", line 11, in <module>
    import bs4
  File "C:\Python34\lib\site-packages\bs4\__init__.py", line 29, in <module>
    from .builder import builder_registry
  File "C:\Python34\lib\site-packages\bs4\builder\__init__.py", line 4, in <module>
    from bs4.element import (
  File "C:\Python34\lib\site-packages\bs4\element.py", line 5, in <module>
    from bs4.dammit import EntitySubstitution
  File "C:\Python34\lib\site-packages\bs4\dammit.py", line 11, in <module>
    from html.entities import codepoint2name
ImportError: No module named 'html.entities'; 'html' is not a package

如果我将每个程序行输入 Python Shell 它工作正常并找到 bs4 等 我重新加载 Python 3.4 并重新安装 BeautifulSoup 并请求并从 .zip 文件重新加载 bs4 文件 但没有改变。就好像 运行 从另一个库执行。如果我从 CMD 行 运行 得到相同的结果。 代码:

import requests, bs4
url="http://www.utexas.edu/world/univ/alpha/"
page = requests.get(url)
page.raise_for_status()
#soup = bs4.BeautifulSoup((page.text), "html.parser")
soup = bs4.BeautifulSoup((page.text),)
print("soup.title ", soup.title)

您有一个名为 html.py 的本地文件,它屏蔽了名为 html 的标准库包。

重命名文件,或将其完全删除。如果您找不到它,请导入它以打印文件名:

import html; print(html.__file__)

一旦完成,html.entities 导入将再次成功。