python - 使用 BeautifulSoup Python 3 时遇到问题

标签 python python-3.x beautifulsoup

无论我使用 bs4、beautifulsoup4 还是 BeautifulSoup,我都会不断获得回溯

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    from BeautifulSoup import BeautifulSoup
ImportError: No module named 'BeautifulSoup'

在终端上我得到

Peters-Mac-mini:~ admin$ pip install beautifulsoup4
Requirement already satisfied (use --upgrade to upgrade): beautifulsoup4 in /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages
Cleaning up...

这是我第一次尝试使用BeautifulSoup,但我在其他安装中从未遇到过此错误。不知道如何摆脱它!我在 Stack Overflow 帖子中没有看到这个问题。

最佳答案

您需要从 bs4 导入,而不是 BeautifulSoup

from bs4 import BeautifulSoup

关于python - 使用 BeautifulSoup Python 3 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27638385/

相关文章:

python - csv.reader 只读一行

python - 结合两个 matplotlib 颜色图

python - 当父记录存在时,如何在 django rest 框架中的子序列化程序中设置外键值

python-3.x - 无法为 pyarrow 构建轮子 - Python 3.9

python - 用 Beautiful Soup 解析 XML

python-2.7 - Python 网页抓取(Beautiful Soup、Selenium 和 PhantomJS): Only scraping part of full page

使用 psutil 的 Python 程序运行 8 小时后失败,并出现 PermissionError : [WinError 5] Access is denied - why?

python - 无法执行 Cloud Function 触发不允许未经身份验证的调用的 HTTP 触发 Cloud Function?

python - BeautifulSoup 汉字编码错误

python - 时尚 MNIST 代码将 bag 作为每个真实世界图像的输出