問題描述
在 AWS Cloud9 中工作,我的腳本是:
Working in AWS Cloud9, my script is:
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 會返回這個:
However, when I run the file, the run configuration hangs until I keyboard interrupt with ctrl+c. Traceback returns this:
> 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 上.非常困難.
Just spent the last 4 hours trying to install chrome and beautifulsoup onto AWS Cloud 9. Very difficult.
我只是讓它運行,直到它自行停止并返回 Message: unknown error: Chrome failed to start: exitedly
I just let it run until it stopped by itself and returned Message: unknown error: Chrome failed to start: exited abnormally
編輯 2:驅動程序信息:chromedriver=2.10.267518,
Edit 2: Driver info: chromedriver=2.10.267518,
平臺=Linux 4.9.85-38.58.amzn1.x86_64 x86_64
platform=Linux 4.9.85-38.58.amzn1.x86_64 x86_64
谷歌瀏覽器 66.0.3359.117
Google Chrome 66.0.3359.117
推薦答案
這個錯誤信息...
Message: unknown error: Chrome failed to start: exited abnormally
...暗示 ChromeDriver 無法建立新的 Chrome 會話.
...implies that the ChromeDriver was unable to establish a new Chrome session.
根據您的問題更新,您的主要問題是您使用的二進制文件之間的版本兼容性,如下所示:
As per your question update your main issue is the version compatibility between the binaries you are using as follows :
- 您正在使用 chromedriver=2.10,它非常old 和 ancient
- 您正在使用 chrome=66.0
- ChromeDriver v2.38 明確提及以下內容:
支持 Chrome v65-67
- 我們不知道您的 Selenium 客戶端 版本.
- 將 Selenium 升級到當前級別版本 3.11.0.
- 將 ChromeDriver 升級到當前的 ChromeDriverv2.38 級別.
- 將 Chrome 版本保持在 Chrome v66.x 級別.(根據 ChromeDriver v2.38 發行說明)
- 清理你的項目工作區通過你的IDE和重建你的項目只需要依賴.
- 使用 CCleaner 工具清除之前和在您的測試套件執行之后.
- 如果您的基礎 Web Client 版本太舊,請通過 卸載它Revo Uninstaller 并安裝最新的 GA 和發布版本的 Web Client.
- 進行一次系統重啟.
- 執行你的
@Test
. - Upgrade Selenium to current levels Version 3.11.0.
- Upgrade ChromeDriver to current ChromeDriver v2.38 level.
- Keep Chrome version at Chrome v66.x levels. (as per ChromeDriver v2.38 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
- If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
@Test
. - WebDriverException:消息:未知錯誤:Chrome 無法啟動:在 VPS 上通過 Python 使用 ChromeDriver Chrome 和 Selenium 異常退出
- WebDriverException:消息:未知錯誤:Chrome 無法啟動:在 VPS 上通過 Python 使用 ChromeDriver Chrome 和 Selenium 異常退出
- WebDriverException:消息:未知錯誤:Chrome 無法啟動:在 VPS 上通過 Python 使用 ChromeDriver Chrome 和 Selenium 異常退出
所以 ChromeDriver 版本 (v2.10) 和 Chrome 瀏覽器 版本 (v66.0)
So there is a clear mismatch between the ChromeDriver version (v2.10) and the Chrome Browser version (v66.0)
您可以在以下位置找到一些相關討論:
You can find a couple of relevant discussions in:
這篇關于消息:未知錯誤:Chrome 無法啟動:在使用 Linux 4.9.85-38.58.amzn1.x86_64 x86_64 的 AWS Cloud9 上異常退出的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!