安装beautifulsoup4和bs4

时间:2018-04-30 01:07:19

标签: python

我曾尝试安装beautifulsoup4和bs4,但它无效。

Python shell模式:

>>> import bs4
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\patff\AppData\Local\conda\conda\envs\k36\lib\site-packages\bs4\__init__.py", line 30, in <module>
    from .builder import builder_registry
  File "C:\Users\patff\AppData\Local\conda\conda\envs\k36\lib\site-packages\bs4\builder\__init__.py", line 250, in <module>
    from .import _htmlparser
  File "C:\Users\patff\AppData\Local\conda\conda\envs\k36\lib\site-packages\bs4\builder\_htmlparser.py", line 13, in <module>
    from bs4.element import (
  File "C:\Users\patff\AppData\Local\conda\conda\envs\k36\lib\site-packages\bs4\element.py", line 5, in <module>
    from bs4.dammit import EntitySubstitution
  File "C:\Users\patff\AppData\Local\conda\conda\envs\k36\lib\site-packages\bs4\dammit.py", line 10, in <module>
    from htmlentitydefs import codepoint2name
ModuleNotFoundError: No module named 'htmlentitydefs'

1 个答案:

答案 0 :(得分:0)

您看到的问题是因为您没有正确导入模块。

请使用“从bs4导入BeautifulSoup”而不是“导入bs4”