Python selenium ChromeDriver がエラー127 で起動しない場合、libgconf2 をインストール

Django Linux
2017-09-11 17:35 (7年前) ytyng
View in English

ubuntu 14.04

Python で、selenium ChromeDriver を起動しようとして

$ xvfb-run ipython
In [3]: from selenium.webdriver import Chrome

In [4]: d = Chrome()
---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-4-0dc1ed148f2d> in <module>()
----> 1 d = Chrome()

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.pyc in __init__(self, executable_path, port, chrome_options, service_args, desired_capabilities, service_log_path)
     60             service_args=service_args,
     61             log_path=service_log_path)
---> 62         self.service.start()
     63
     64         try:

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.pyc in start(self)
     94         count = 0
     95         while True:
---> 96             self.assert_process_still_running()
     97             if self.is_connectable():
     98                 break

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.pyc in assert_process_still_running(self)
    107             raise WebDriverException(
    108                 'Service %s unexpectedly exited. Status code was: %s'
--> 109                 % (self.path, return_code)
    110             )
    111

WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

となったら。

まず、chromedriver 単体で起動してみる

$ chromedriver
chromedriver: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory

→ 起動失敗

libgconf2 をインストール

$ apt search libgconf

...

$ sudo apt install libgconf2-4

chromedriver を再実行してみる

$ chromedriver
Starting ChromeDriver 2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5) on port 9515
Only local connections are allowed.

起動した!

再度Python から実行

$ xvfb-run ipython
In [1]: from selenium.webdriver import Chrome

In [2]: d = Chrome()

In [3]:

 起動した!

現在の評価: 4.1
タイトルとURLをコピー

コメント

アーカイブ

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011