Python chromium浏览器意外退出(Ubuntu服务器)
我似乎无法让Chromedriver与Ubuntu一起工作。我在AWS(EC2)上运行Ubuntu。我检查了Python chromium浏览器意外退出(Ubuntu服务器),python,google-chrome,ubuntu,amazon-ec2,selenium-chromedriver,Python,Google Chrome,Ubuntu,Amazon Ec2,Selenium Chromedriver,我似乎无法让Chromedriver与Ubuntu一起工作。我在AWS(EC2)上运行Ubuntu。我检查了/usr/bin,发现里面有以下软件包: chromedriver chromium-browser 因此,我的代码如下: options = Options() options.binary_location = '/usr/bin/chromium-browser' options.add_argument('--headless') options.a
/usr/bin
,发现里面有以下软件包:
chromedriver
chromium-browser
因此,我的代码如下:
options = Options()
options.binary_location = '/usr/bin/chromium-browser'
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--remote-debugging-port=9222")
driver = webdriver.Chrome(executable_path='/usr/bin/chromium-browser', chrome_options=options)
我得到了以下错误:
Traceback (most recent call last):
File "test.py", line 40, in <module>
driver = webdriver.Chrome(executable_path='/usr/bin/chromium-browser', chrome_options=options)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/chromium-browser unexpectedly exited. Status code was: 1
回溯(最近一次呼叫最后一次):
文件“test.py”,第40行,在
driver=webdriver.Chrome(可执行文件路径='/usr/bin/chromiubrowser',Chrome\u options=options)
文件“/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py”,第73行,在__
self.service.start()
文件“/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py”,第98行,开始
self.assert\u进程\u仍在运行()
文件“/usr/local/lib/python3.6/dist packages/selenium/webdriver/common/service.py”,第111行,断言进程仍在运行
%(self.path,返回\u代码)
selenium.common.exceptions.WebDriverException:消息:Service/usr/bin/chromium浏览器意外退出。状态代码为:1
如果我查看当前的Chrome浏览器版本,就会发现我使用的是78.0.3904.70版。我使用的驱动程序可能已经过时了吗
我还想知道:Chrome浏览器和Chromedriver之间有什么区别?我以前使用Chromedriver登录Chrome与Selenium一起使用。您需要将可执行路径设置为
Chromedriver
,因为这正是Selenium
使用的。因此,代码行需要:
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', chrome_options=options)
谢谢-我有一个新的错误;WebDriverException:消息:无法访问chrome。这是否意味着我需要降级chrome版本?谢谢您的帮助。请尝试添加此选项:
chrome\u选项。添加参数('--no sandbox')
这已在我的代码:选项中。添加参数('--no sandbox')。请看我的原始代码。对不起,我错过了。我认为问题在于chromedriver和Selenium的版本不兼容。我该如何解决这个问题?!