【发布时间】:2020-05-15 11:38:17
【问题描述】:
我从 Python - Selenium 开始,我无法运行 Python 的 Beautiful Soup 库。我已经安装了 Python 版本 3.8.2 并准备了 Beautiful Soup 4 的 4.9.0 版本。当我检查 cmd 并询问这个库时,会说“要求已经满足:c:...\python38-32 中的beautifulsoup4 \lib\site-packages (4.9.0)”。该库已由 cmd 手动安装。但问题是,当我尝试在 PyCharm 中使用 Beautiful Soup 时,脚本每次都会以以下错误结束:
'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'<>'You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).'
函数被调用:
from bs4 import BeautifulSoup
请问我做错了什么? Python和Beautiful Soup的版本不兼容还是错误在其他地方?我需要从网站数据表中抓取表格,但如果不使用 Beautiful Soup,我找不到其他选择。
非常感谢。
【问题讨论】:
-
你试过
pip install -u beautifulsoup4吗? -
你能从 python 3 IDE 运行 bs4。好像 pycharm 有 python2 Sdk 路径而不是 python 3。
标签: python selenium beautifulsoup