【问题标题】:Beautiful Soup install error - Python - SeleniumBeautiful Soup 安装错误 - Python - Selenium
【发布时间】: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


【解决方案1】:

尝试在 PyCharm 中手动安装:

Files > Settings > Projects(to the left)> python interpreter>  click on '+' symbol (to 
   the left) and search for beautifulsoup4 and click on install packages.

还要检查您在 PyCharm 中使用的 python 版本。

【讨论】:

    猜你喜欢
    • 2014-06-28
    • 1970-01-01
    • 2022-10-15
    • 2014-08-10
    • 2014-05-31
    • 2017-12-05
    • 1970-01-01
    • 1970-01-01
    • 2014-04-21
    相关资源
    最近更新 更多