732E772E
732E772E

Reputation: 201

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.

Upvotes: 4

Views: 3541

Answers (2)

STA
STA

Reputation: 1

Put chromedriver.exe and your program in the same directory.

Upvotes: 0

Alexey Savchenko
Alexey Savchenko

Reputation: 11

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.

Upvotes: 1

Related Questions