1

我成功安装了 bs4,但是当我导入它时,命令行告诉我

Traceback (most recent call last): 
  Python Shell, prompt 3, line 1
  File "C:\Python27\Lib\site-packages\bs4\__init__.py", line 303, in <module>
    from . import _htmlparser 
  File "C:\Python27\Lib\site-packages\bs4\_htmlparser.py", line 36, in <module>
    from bs4.builder import (
ImportError: No module named builder

我搜索了谷歌,但没有找到解决方案。我们的专家可以帮助我解决这个问题吗?

多谢 !

我的系统信息:PC 操作系统:Windows 7 64 位 Python 版本:2.7.10

4

2 回答 2

0

你必须先pip install beautifulsoup4,然后再尝试import bs4。如果这不起作用,那么您的 pip 配置很混乱。为了解决这个问题,请重新安装 pip,使用 easy_install 或从源代码构建。

为了使用 easy_install 只需运行easy_install beautifulsoup4. 为了从源代码构建,请运行下载并解压缩此 zipunzip /path/to/beautifulsoup4.zip如果您在终端上)。接下来通过执行并运行cd进入现在解压缩的文件夹。现在将安装包并准备导入!cd /path/to/beautifulsouppython setup.py

于 2015-08-30T04:27:29.453 回答
-1

我卸载了 bs4 包并重新安装了它。现在它可以工作了......

这很奇怪,因为我试图卸载并重新安装,但只有这一次,它起作用了......

感谢您的帮助:)

于 2015-08-30T05:50:55.117 回答