简体   繁体   中英

selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited

I am aware of very similar questions having been asked already but even after a few hours of googling, researching and comparing I can't figure out what the problem is. My ultimate goal is to do some web scraping with Python using selenium but for now I can't even get the webdriver to start. This is the code and the error message that I've got so far:

$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyvirtualdisplay import Display
>>> from selenium import webdriver
>>> 
>>> display = Display(visible=0, size=(1024, 768))
>>> display.start()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '1024x768x24', ':1069'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '1024x768x24', ':1069'] oserror=None return_code=None stdout="None" stderr="None" timeout_happened=False>
>>> d = webdriver.Chrome()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
    self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 96, in start
    self.assert_process_still_running()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1

The chromedriver version is 2.30 and is located at:

$ ll /usr/local/bin/chromedriver
-rwxr-xr-x 1 stefan stefan 8475456 Jun  7 15:53 /usr/local/bin/chromedriver

Since it's in /usr/local/bin I do not need to specify the path when instantiating the webdriver as in d = webdriver.Chrome("/path/to/chromedriver") .

Before I was able to run above code I installed google Chrome browser, xvfb, pyvirtualdisplay and selenium. The commands I used where:

sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get install -f
sudo apt-get install xvfb
wget -N http://chromedriver.storage.googleapis.com/2.30/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/local/bin
sudo pip install pyvirtualdisplay selenium

So, I have the latest versions of all the software. Any help as to what the solution to my problem could be is greatly appreciated. Thank you very much in advance.

Have got the same problem when I ran process with selenium and PhantomJs driver through nohup (Also mentioned there ) I needed to capture output in virtual machine and not depend on opened session.

I started using tmux for that purpose which does not block signals like nohup does and the problem has disappeared.

将 chromedriver.exe 和您的程序放在同一目录中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Docker Selenium: selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127 selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1 selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited with ChromeDriver Selenium Python on Linux selenium.common.exceptions.WebDriverException: Message: chromedriver unexpectedly exited. Status code was: 255 When using Dockerfile webDriverException "selenium.common.exceptions.WebDriverException: Message: Service ./webdrivers/geckodriver unexpectedly exited. Status code was: 1" selenium.common.exceptions.WebDriverException: Message: Service unexpectedly exited. Status code was: 3221225595 selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: -11 - How to fix? selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 69 selenium.common.exceptions.WebDriverException: Message: Service .\geckodriver.exe unexpectedly exited. Status code was: 3221225595 selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM