从bs4导入BeautifulSoup4

时间:2020-09-22 14:57:49

标签: python-3.x beautifulsoup pip

我已经安装了所有软件包,但是当我尝试导入from bs4 import BeautifulSoup4时遇到此错误Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> from bs4 import BeautifulSoup4 ImportError: cannot import name 'BeautifulSoup4' from 'bs4' (C:\xxx\xxx\xxx\Local\Programs\Python\Python38-32\lib\site-packages\bs4\__init__.py)

有人知道为什么要得到这个吗?

1 个答案:

答案 0 :(得分:-1)

您将改为使用from bs4 import BeautifulSoup

查看documentation for Beautiful Soup,其示例使用模块名称BeautifulSoup而不是BeautifulSoup 4 导入。