1

I'm trying to use Selenium Webdriver in Python project (at Ubuntu 20.04.3 LTS x86_64)

Error:

<stdin>:1: DeprecationWarning: use options instead of chrome_options
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1

Code:

# Setup selenium
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

PROBLEM STARTS HERE

wd = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
PDD
  • 71
  • 7

2 Answers2

0

Taken from another similar post "chrome_options is deprecated now and you have to use options instead as well as pass the absolute path of the ChromeDriver along with the extension." I think the code below might work since your chrome driver should be in /usr/bin due to the script

# Setup selenium
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
import sys
sys.path.insert(0,'/usr/lib/chromium-browser/chromedriver')
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome(executable_path='/usr/bin/chromedriver',options=options)
  • chrome_options is deprecated ??? From where did you get that reference ? – cruisepandey Oct 09 '21 at 07:33
  • Sure! I got it from here https://stackoverflow.com/questions/63310119/deprecationwarning-use-options-instead-of-chrome-options-error-using-chromedriv – since9teen94 Oct 09 '21 at 11:39
  • @since9teen94 same errors :( I'm trying to local installation https://colab.research.google.com/github/tomasonjo/blogs/blob/master/harry_potter/HarryPotterNLP.ipynb but do something wrong at Fedora 34 and Ubuntu (through Docker). – PDD Oct 09 '21 at 11:52
  • I think to downgrade python version to 3.6-3.7 as inside Colab Notebook – PDD Oct 09 '21 at 15:00
  • 1
    It's definitely worth a shot. if you need to remove neuralcoref, you can use 'rm -rf neuralcoref' and maybe use 'apt-get upgrade' after the 'apt-get update' command. Definitely start with downgrading though! – since9teen94 Oct 09 '21 at 16:16
0

Please check the driver version with the chromium version should be similar