【问题标题】:selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1selenium.common.exceptions.WebDriverException:消息:服务 chromedriver 意外退出。状态码是:1
【发布时间】:2020-05-15 13:22:23
【问题描述】:

我是 Python 编程的新手,目前正在学习 Selenium,所以请原谅这个很可能是初学者级别的问题。

我使用 Homebrew 安装了 Selenium,然后我尝试在我的终端上执行它。

from selenium import webdriver 
webdriver.Chrome()

然后我收到此错误消息。

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1

我发现了类似的错误消息,但状态代码不同,因此无论是在文档中还是在 StackOverflow 上,我都找不到解决此问题的方法。

【问题讨论】:

  • 你下载Chrome驱动了吗?如果是这样,请确保您下载的驱动程序版本与您的 Chrome 版本匹配。
  • 是的,我下载了 Chromedriver。我刚刚成功重新安装了它,我刚刚检查了一下,我的 Chrome 是最新的。这是否意味着它不是与不同版本的 Chrome 和驱动程序有关的问题?
  • 您的 Chrome 是最新的,但 Chrome 的版本是否与驱动程序的版本匹配?
  • 当我运行chomedriver --version 时,它会输出这个/Users/Benjamin/.rbenv/libexec/rbenv-exec: line 47: /Users/Benjamin/.rbenv/versions/2.2.3/bin/chromedriver: Bad CPU type in executable 不太清楚这意味着什么,但可能是问题所在吗?
  • 你刚刚写了“chomedriver”。那只是一个错字吗?如果是mac,试试discussions.apple.com/thread/250777998?

标签: python selenium selenium-webdriver selenium-chromedriver


【解决方案1】:

问题是您缺少 ChromeDriver,

首先,找到您使用的是哪个版本的 Chrome:

  • 点击右上角的三个点(在 Chrome 中)
  • 帮助
  • 关于谷歌浏览器

其次,找到并下载合适的ChromeDriver版本

第三,解压压缩包,移动到usr/local/bin文件夹。

usr/local/bin 路径在 macOS 上适用于我,可能因操作系统不同而不同)

【讨论】:

    猜你喜欢
    • 2017-11-30
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    • 2021-09-03
    • 2019-05-31
    相关资源
    最近更新 更多