在ec2实例上使用python脚本打开Chrome浏览器
我正在运行这个python脚本来打开我的chrome浏览器。我正在使用selenium的ec2实例上运行我的脚本。我已经在我的实例上安装了selenium和所需的包。这是我的脚本在ec2实例上使用python脚本打开Chrome浏览器,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我正在运行这个python脚本来打开我的chrome浏览器。我正在使用selenium的ec2实例上运行我的脚本。我已经在我的实例上安装了selenium和所需的包。这是我的脚本 from selenium import webdriver # The place we will direct our WebDriver to url = 'http://www.srcmake.com/' # Creating the WebDriver object using the ChromeD
from selenium import webdriver
# The place we will direct our WebDriver to
url = 'http://www.srcmake.com/'
# Creating the WebDriver object using the ChromeDriver
driver = webdriver.Chrome()
# Directing the driver to the defined url
driver.get(url)
但是当我运行这个脚本时,我得到了这个错误
Traceback (most recent call last):
File "main.py", line 7, in <module>
driver = webdriver.Chrome()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
回溯(最近一次呼叫最后一次):
文件“main.py”,第7行,在
driver=webdriver.Chrome()
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/chrome/webdriver.py”,第73行,在__
self.service.start()
文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py”,第98行,开始
self.assert\u进程\u仍在运行()
文件“/usr/local/lib/python2.7/dist packages/selenium/webdriver/common/service.py”,第111行,断言进程仍在运行
%(self.path,返回\u代码)
selenium.common.exceptions.WebDriverException:消息:服务chromedriver意外退出。状态代码为:127
如何解决此问题?您需要按如下方式使用chromedriver二进制文件:
driver = webdriver.Chrome('/usr/local/bin/chromedriver.exe')
根据您的chrome版本从以下位置下载chromedriver: