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
2.3k views
in Technique[技术] by (71.8m points)

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

I'd like to construct my crawler using selenium on my server.

Thus I had installed/download required dependencies- such as chromedriver, chromium-browser etc on my Ubuntu17.10 server

However, when I run following code:

driver = webdriver.Chrome()

It returns following error:

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-14-2cdab8938403> in <module>()
----> 1 driver = webdriver.Chrome()

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options)
     66             service_args=service_args,
     67             log_path=service_log_path)
---> 68         self.service.start()
     69 
     70         try:

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self)
     96         count = 0
     97         while True:
---> 98             self.assert_process_still_running()
     99             if self.is_connectable():
    100                 break

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
    109             raise WebDriverException(
    110                 'Service %s unexpectedly exited. Status code was: %s'
--> 111                 % (self.path, return_code)
    112             )
    113 

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

What does it mean that it's excited..?

I can't get what the original intention of that error code and where to start to fix it.

It looks very rare case.

Maybe relevant:

I had install ubuntu desktop 17.10 on my desktop but failed to get GUI boot. Thus I am just using terminal only, but it well works so far. I had installed ssh and remote controlling jupyter notebook from my mac to server desktop, and those errors comes from it. Hope this info is relevant to solve this error, otherwise will abort it.

Question&Answers:os

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

1 Reply

0 votes
by (71.8m points)

It seems chromedriver needs some extra libraries. This solved the issue for me:

apt-get install -y libglib2.0-0=2.50.3-2 
    libnss3=2:3.26.2-1.1+deb9u1 
    libgconf-2-4=3.2.6-4+b1 
    libfontconfig1=2.11.0-6.7+b1

I was working on a similar setup using a docker container instead of a server/VM without X / GUI.

To figure out which dependencies are required I tried iteratively to run it from the command line like this: /opt/chromedriver/2.33/chromedriver --version over and over again.

Then at eache time I used commands like apt-cache search <STUFF> and apt-cache madison <STUFF> to figure out the exact version of the deb package needed by chromedriver 2.33 (in my case, but I guess something similar would work for any version of chromedriver).


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

...