2

I’m losing my mind trying to get selenium with chromedriver working on ubuntu server. I’ve already posted about this issue in:

https://stackoverflow.com/questions/55624355/the-process-started-from-chrome-location-usr-bin-google-chrome-is-no-longer-run

Where is was pointed out that my chromedriver didn’t match my google chrome version. So I’ve uninstalled google chrome and removed the chromedriver. Done a fresh install on google chrome and re-downloaded chromedriver. I’ve found some posts that suggested moving the chromedriver to the bin/chromedriver directory. So I did that as well. But I’m still getting the same error.

I’m trying to run this code in a jupyter notebook.

Any tips are greatly appreciated, I’m down to animal sacrifice and tossing coins in a well.

Ubuntu code:

Uninstalling google chrome and chromedriver:

sudo apt-get purge chromium-browser

rm ~/.config/chromium/ -rf

sudo apt-get purge google-chrome-stable

rm ~/.config/google-chrome/ -rf


sudo apt-get purge chromiumdriver

sudo apt-get purge chromedriver

Installing google chrome:

sudo apt-get install -y libappindicator1 fonts-liberation

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo dpkg -i google-chrome*.deb

sudo apt-get -f install

Copying chromedriver to bin:

sudo cp chromedriver /usr/bin/chromedriver

sudo chown root:root /usr/bin/chromedriver

sudo chmod +x /usr/bin/chromedriver


google-chrome --version

output:

Google Chrome 73.0.3683.103

chromedriver --version

output:

ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72)

Jupyter notebook code:

import pandas as pd
import numpy as np

import os

from selenium import webdriver
from selenium.webdriver.chrome.options import Options


Options

options = Options()

chrome_options = Options() 


options.add_argument('headless') #downlod Chrome driver.exe 
#driver = webdriver.Chrome(executable_path=os.path.abspath("/home/username/stuff/JobHuntCode/chromedriver"), chrome_options=chrome_options)
driver = webdriver.Chrome(executable_path=os.path.abspath("/home/username/chromedriver"), chrome_options=chrome_options)

Error:

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-1-9a59a3a16e54> in <module>
     19 options.add_argument('headless') #downlod Chrome driver.exe
     20 #driver = webdriver.Chrome(executable_path=os.path.abspath("/home/username/stuff/JobHuntCode/chromedriver"), chrome_options=chrome_options)
---> 21 driver = webdriver.Chrome(executable_path=os.path.abspath("/home/username/chromedriver"), chrome_options=chrome_options)
     22 # driver = webdriver.Chrome()
     23 

~/anaconda3/envs/py36/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, keep_alive)
     79                     remote_server_addr=self.service.service_url,
     80                     keep_alive=keep_alive),
---> 81                 desired_capabilities=desired_capabilities)
     82         except Exception:
     83             self.quit()

~/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
    155             warnings.warn("Please use FirefoxOptions to set browser profile",
    156                           DeprecationWarning, stacklevel=2)
--> 157         self.start_session(capabilities, browser_profile)
    158         self._switch_to = SwitchTo(self)
    159         self._mobile = Mobile(self)

~/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, capabilities, browser_profile)
    250         parameters = {"capabilities": w3c_caps,
    251                       "desiredCapabilities": capabilities}
--> 252         response = self.execute(Command.NEW_SESSION, parameters)
    253         if 'sessionId' not in response:
    254             response = response['value']

~/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
    319         response = self.command_executor.execute(driver_command, params)
    320         if response:
--> 321             self.error_handler.check_response(response)
    322             response['value'] = self._unwrap_value(
    323                 response.get('value', None))

~/anaconda3/envs/py36/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
    240                 alert_text = value['alert'].get('text')
    241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
    243 
    244     def _value_or_default(self, obj, key, default):

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.15.0-46-generic x86_64)
user3476463
  • 3,967
  • 22
  • 57
  • 117
  • You copy `chromedriver` to `/usr/bin/` and make it executable, but, in your code you point to `/home/username/chromedriver`. – jackw11111 Apr 15 '19 at 00:01
  • 1
    @jackw11111 Thanks for pointing that out, I changed the code to "driver = webdriver.Chrome(executable_path=os.path.abspath("/usr/bin/chromedriver"), chrome_options=chrome_options) " but I'm still getting the same error. – user3476463 Apr 23 '19 at 02:00
  • 1
    @jackw11111 I added the following 3 lines to my jupyter notebook and it solved my issue, do you know what they do? "chrome_options.add_argument("no-sandbox") chrome_options.add_argument("--disable-extensions") chrome_options.add_argument("--headless")" – user3476463 Apr 27 '19 at 21:58
  • I would guess the sandbox is for google development API, disabling extensions might help with debugging and running chrome headless runs without opening a GUI instance. I couldn't reproduce the error so I'm not sure how they have affected it, but I guess as long as its working is what matters :) – jackw11111 Apr 28 '19 at 04:27
  • @user3476463 did you find a solution? Could you please share with us? I'm looking for the same thing. Cheers! – Lara Feb 11 '20 at 19:40

0 Answers0