使用BeautifulSoup Python 3时出现问题

使用BeautifulSoup Python 3时出现问题,python,python-3.x,beautifulsoup,Python,Python 3.x,Beautifulsoup,无论我使用bs4、beautifulsoup4还是beautifulsoup4,我都会不断得到回溯 Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> from BeautifulSoup import BeautifulSoup ImportError: No module named 'BeautifulSoup' 这是我第一次尝试使用BeautifulSo

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

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

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

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

from bs4 import BeautifulSoup

每个版本中的模块名称并不总是相同的

这会有帮助

from bs4 import BeautifulSoup
如果您想要导入
beautifulsou

你可以这样做:

try:
   from bs4 import BeautifulSoup
except ImportError:
   from BeautifulSoup import BeautifulSoup

从BeautifulSoup导入BeautifulSoup
将适用于bs3。对于bs4,使用bs4导入BeautifulSoup中的
@tanaydin:这绝对是胡说八道。如果安装了lxml,则BeautifulSoup 4将使用lxml。这两个API都有各自的优点。我得到:>>>来自bs4导入美化组的回溯(最近一次调用):文件“”,第1行,来自bs4导入美化组导入错误:没有名为“bs4”的模块我不知道我做了什么来自:来自bs4导入美化组。我删除了BeautifulSoup并重新安装。在我的/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages中,我有两个文件夹。beautifulsoup4-4.3.2-py3.2.egg-info和bs4。我假设BeautifulSoup在bs4文件夹的init文件中,如果我使用第二个示例,我得到一个导入错误modules existI used>help()>modules。我应该在模块列表中看到漂亮的汤吗?那里什么都没有
try:
   from bs4 import BeautifulSoup
except ImportError:
   from BeautifulSoup import BeautifulSoup