gpt4 book ai didi

python - 尝试导入 BeautifulSoup 时出现异常

转载 作者:太空宇宙 更新时间:2023-11-03 18:38:51 24 4
gpt4 key购买 nike

我正在尝试将 Beautiful Soup4-4.1.0 导入 Python 3.3(我已将 Beautiful Soup 放入: C:\Python33\Lib\site-packages\BeautifulSoup\bs4 )。

使用以下内容:

from BeautifulSoup import bs4

我收到以下错误:

Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
from BeautifulSoup import bs4
File "C:\Python33\lib\site-packages\BeautifulSoup\bs4\__init__.py", line 175
except Exception, e:

谁能帮忙解决这个问题吗?

最佳答案

我建议你阅读BeautifulSoup documentation因为我引用:

Beautiful Soup 4 works on both Python 2 (2.6+) and Python 3.

无论如何,BeautifulSoup 4 都是通过 PyPi 发布的,所以如果你无法使用系统打包器安装它,你可以使用 easy_install 或 pip 安装它。包名称为 beautifulsoup4,相同的包适用于 Python 2 和 Python 3。

$ easy_install beautifulsoup4

$ pip install beautifulsoup4

如果您没有安装easy_install或pip,您可以下载BeautifulSoup 4源 tarball 并使用 setup.py 安装它。 [转到该文件夹​​并运行命令 setup.py install (假设 *.py 在路径扩展名中已知,否则运行

c:\pythonXX\python setup.py install).

关于python - 尝试导入 BeautifulSoup 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21008959/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com