gpt4 book ai didi

python - 导入错误 : No module named bs4?

转载 作者:太空宇宙 更新时间:2023-11-04 07:06:40 24 4
gpt4 key购买 nike

我尝试导入库:from bs4 import BeautifulSoup

当我运行脚本时出现错误:

Traceback (most recent call last):
File "index.py", line 9, in <module>
from bs4 import BeautifulSoup
ImportError: No module named bs4
root@srvr [/home/public_html/grabber/similar]#

当我尝试安装时:

pip install beautifulsoup4

我收到以下错误:

Requirement already satisfied: beautifulsoup4 in /usr/lib/python2.6/site-packages/beautifulsoup4-4.5.1-py2.6.egg

脚本是:

import sys
sys.path.append('/usr/lib/python2.6/site-packages')
from bs4 import BeautifulSoup

最佳答案

您安装了适用于 Python 2.6 的 BeautifulSoup,但根据您的标签,您使用的是 Python 3.x。要为 Python 3 显式安装,请使用 pip3 而不是 pip,即

pip3 install beautifulsoup4

关于python - 导入错误 : No module named bs4?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40975182/

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