我尝试导入库: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
