【问题标题】:chromium-browser unexpectedly quit (Ubuntu Server)chromium-browser 意外退出(Ubuntu 服务器)
【发布时间】:2020-02-23 07:11:35
【问题描述】:

我似乎无法让 Chromedriver 与 Ubuntu 一起使用。我在 AWS (EC2) 上运行 Ubuntu。我检查了/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

如果我检查我当前的 Chrome 浏览器版本,我发现我使用的是 78.0.3904.70 版本。我使用的驱动程序是否可能已过期?

我也想知道:chromium-browser 和 Chromedriver 有什么区别?我过去使用 Chromedriver 登录 Chrome 以与 Selenium 一起使用。

【问题讨论】:

    标签: python google-chrome ubuntu amazon-ec2 selenium-chromedriver


    【解决方案1】:

    您需要将可执行路径设置为chromedriver,因为这是selenium 使用的。所以那行代码需要是:

    driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', chrome_options=options) 
    

    【讨论】:

    • 谢谢 - 我新收到一个新错误; WebDriverException:消息:chrome 无法访问。这是否意味着我需要降级 chrome 版本?感谢您的帮助。
    • 尝试添加这个选项:chrome_options.add_argument('--no-sandbox')
    • 这已经在我的代码中了:options.add_argument('--no-sandbox')。查看我的原始代码..
    • 对不起,我错过了。我认为问题是 chromedriver 和 Selenium 的版本不兼容。
    • 我该如何解决这个问题?!
    猜你喜欢
    • 2019-04-20
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    相关资源
    最近更新 更多