一尘不染

消息:未知错误:Chrome无法启动:在具有Linux 4.9.85-38.58.amzn1.x86_64 x86_64的AWS Cloud9上异常退出

selenium

在AWS Cloud9中工作,我的脚本是:

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import requests


options = Options()
options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(chrome_options=options, executable_path='/home/ec2-user/environment/downloads/chromedriver')
url = 'http://google.com'
driver.get(url)

soup = BeautifulSoup(driver.page_source, 'lxml')

# driver.quit()

print(soup)

但是,当我运行文件时,运行配置将挂起,直到我用ctrl + c键盘中断为止。追溯返回此:

> Traceback (most recent call last):   File
> "/home/ec2-user/environment/vpy36/lib/python3.6/dist-packages/hubspot-marketplace.py",
> line 9, in <module>
>     driver = webdriver.Chrome(chrome_options=options, executable_path='/home/ec2-user/environment/downloads/chromedriver')  
> File
> "/home/ec2-user/environment/vpy36/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py",
> line 75, in __init__
>     desired_capabilities=desired_capabilities)   File "/home/ec2-user/environment/vpy36/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 154, in __init__
>     self.start_session(desired_capabilities, browser_profile)   File "/home/ec2-user/environment/vpy36/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 243, in start_session
>     response = self.execute(Command.NEW_SESSION, parameters)   File "/home/ec2-user/environment/vpy36/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py",
> line 310, in execute
>     response = self.command_executor.execute(driver_command, params)   File
> "/home/ec2-user/environment/vpy36/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py",
> line 466, in execute
>     return self._request(command_info[0], url, body=data)   File "/home/ec2-user/environment/vpy36/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py",
> line 490, in _request
>     resp = self._conn.getresponse()   File "/usr/lib64/python3.6/http/client.py", line 1331, in getresponse
>     response.begin()   File "/usr/lib64/python3.6/http/client.py", line 297, in begin
>     version, status, reason = self._read_status()   File "/usr/lib64/python3.6/http/client.py", line 258, in _read_status
>     line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")   File "/usr/lib64/python3.6/socket.py", line 586, in readinto
>     return self._sock.recv_into(b) KeyboardInterrupt

刚刚花了最后4个小时尝试将chrome和beautifulsoup安装到AWS Cloud 9上。非常困难。

编辑:我只是让它运行,直到它自己停止并返回 Message: unknown error: Chrome failed to start: exited abnormally

编辑2:驱动程序信息:chromedriver = 2.10.267518,

平台= Linux 4.9.85-38.58.amzn1.x86_64 x86_64

谷歌浏览器66.0.3359.117


阅读 301

收藏
2020-06-26

共1个答案

一尘不染

此错误消息…

Message: unknown error: Chrome failed to start: exited abnormally

…表示 ChromeDriver 无法建立新的 Chrome 会话。

根据您的问题更新,您的主要问题是所使用的二进制文件之间的 版本兼容性 ,如下所示:

  • 您正在使用 chromedriver = 2.10 ,它相当 古老古老
  • 您正在使用 chrome = 66.0
  • ChromeDriver v2.38的 发行说明中明确提到以下内容:

支持 Chrome v65-67

  • 我们不知道您的 Selenium Client 版本。

因此, ChromeDriver 版本( v2.10 )与 Chrome浏览器 版本( v66.0 )之间存在明显的不匹配

  • Selenium 升级到当前 版本3.11.0
  • 升级 ChromeDriver 当前 ChromeDriver v2.38 水平。
  • Chrome 版本保持在 Chrome v66.x 级别。(根据ChromeDriver v2.38发行说明
  • 清理 你的 项目工作 ,通过你的 IDE重建 仅需要依赖你的项目。
  • 在执行 测试套件 之前和之后,使用 CCleaner 工具清除所有操作系统琐事。 __
  • 如果您的基本 Web客户端 版本太旧,请通过 Revo Uninstaller 卸载它,然后安装最新的GA和 Web客户端 发行版本。
  • 进行 系统重启
  • 执行您的@Test

2020-06-26