【问题标题】:Error : Could not find a version that satisfies the requirement webdriver (from versions: )错误:找不到满足 webdriver 要求的版本(来自版本:)
【发布时间】:2023-03-20 12:21:01
【问题描述】:

嗨,我是 python 的新开发人员 我想使用 selenium web driver api 并使用 mac pc 并安装 web 驱动程序库

我在pycharm项目解释器上安装代码'pip install web driver'但是错误

错误定义如下:

  Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/bin/python3.5'.




  Could not find a version that satisfies the requirement webdriver (from versions: )
No matching distribution found for web driver

注意:我使用 python 3.5 但终端使用 2.7 :(

没有找到与 Web 驱动程序匹配的分发版

你能帮帮我吗

祝你好运……

【问题讨论】:

  • 我真的很困惑。你到底想做什么?要安装 selenium,您需要安装 selenium。不是网络驱动程序。所以应该是pip install selenium

标签: python macos selenium selenium-webdriver automated-tests


【解决方案1】:

这不是很清楚的记录,但你不能从 pypi 安装 webdriver,但需要安装 selenium,然后它会为你提供 webdriver。

sudo pip install selenium

应该可以解决问题。或者对于现代python:

sudo python3 -m pip install selenium

您还需要安装 geckodriver(适用于 Firefox)或 chromedriver(适用于 Chrome 和 Chromium)并将其放在您的路径中,以便能够实例化 webdriver 对象。

之后像下面这样的事情应该工作:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://stackoverflow.com/questions/34256762/error-could-not-find-a-version-that-satisfies-the-requirement-webdriver-from")

【讨论】:

  • 我正在尝试但抛出错误 Traceback (最近一次调用最后一次): driver = webdriver.Firefox() File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver. py”,第 77 行,在 init self.binary,超时),
  • 我可以在未安装 Firefox 的系统上重现此错误消息。安装 Firefox 后,错误消失了,我得到了预期的 Firefox 窗口。
【解决方案2】:

您可以尝试以下方式,如果您不知道路径,请使用!apt install chromium-chromedriver

!pip install selenium
!pip install webdriver-manager
!apt-get update # to update ubuntu to correctly run apt install
!apt install chromium-chromedriver

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import requests

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
driver =webdriver.Chrome('chromedriver',chrome_options=chrome_options)

【讨论】:

    【解决方案3】:

    我在 Ubuntu 上遇到了类似的问题。我想安装一个特定的 Selenium 版本,但我不确定确切的标签,因为 Dockerhub 上的标签有点不同。 所以我的步骤是:

    1 转至https://pypi.org/project/selenium/#files

    2 单击Release history 选项卡

    3 找到我需要的特定版本。就我而言,它是 4.0.0.a7

    4 从 Linux 终端执行:

    pip install selenium==4.0.0.a7
    

    【讨论】:

      猜你喜欢
      • 2020-07-24
      • 1970-01-01
      • 2019-04-15
      • 2020-02-12
      • 2016-12-29
      • 1970-01-01
      • 2021-02-11
      • 2020-09-24
      • 2020-12-05
      相关资源
      最近更新 更多