Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
412 views
in Technique[技术] by (71.8m points)

python - Message: unknown error: Chrome failed to start: exited abnormally on AWS Cloud9 with Linux 4.9.85-38.58.amzn1.x86_64 x86_64

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)

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

Just spent the last 4 hours trying to install chrome and beautifulsoup onto AWS Cloud 9. Very difficult.

Edit: I just let it run until it stopped by itself and returned Message: unknown error: Chrome failed to start: exited abnormally

Edit 2: Driver info: chromedriver=2.10.267518,

platform=Linux 4.9.85-38.58.amzn1.x86_64 x86_64

Google Chrome 66.0.3359.117

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This error message...

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

...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 :

  • You are using chromedriver=2.10 which pretty old and ancient
  • You are using chrome=66.0
  • Release Notes of ChromeDriver v2.38 clearly mentions the following :

Supports Chrome v65-67

  • Your Selenium Client version is unknown to us.

So there is a clear mismatch between the ChromeDriver version (v2.10) and the Chrome Browser version (v66.0)

Solution

  • 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.

References

You can find a couple of relevant discussions in:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...