ModuleNotFoundError:即使安装并重新安装后,也没有名为“ bs4”的模块

时间:2019-04-28 14:29:54

标签: python python-3.x beautifulsoup

我正在尝试运行我的Python文件。 (py name.py)

    from bs4 import BeautifulSoup as BS
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\__init__.py", line 29, in <module>
    from .builder import builder_registry
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
    from . import _htmlparser
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
    from html.parser import (
ImportError: cannot import name 'HTMLParseError' from 'html.parser' (C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\html\parser.py)

我使用“ pip”安装了该库。 完全删除并重新安装该库之后,运行此代码时将出现此错误。

  File "name.py", line 9, in <module>
from bs4 import BeautifulSoup as BS
ModuleNotFoundError: No module named 'bs4'

1 个答案:

答案 0 :(得分:1)

我解决了这个问题。首先,我从PC中删除了所有BS4提及内容。然后在CMD中继续前进:

C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts

并在其中使用了命令:

pip install beautifulsoup4