0

I am trying to write a simple web bot in Python. I have installed selenium and chromedriver. My OS is Linux Mint and IDE PyCharm.

I have followed instructions here:

    https://bangladroid.wordpress.com/2016/08/10/how-to-install-chrome-driver-in-linux-mint-selenium-webdriver/

Here is my code:

    from selenium import webdriver

    driver = webdriver.Chrome("/usr/bin/chromedriver")
    driver.get("http:google.com")
    

And traceback:

    Traceback (most recent call last):
      File "/home/kajetan/PycharmProjects/FirstBot/bot.py", line 3, in <module>
        driver = webdriver.Chrome("/usr/bin/chromedriver")
      File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py",                 line 73, in __init__
        self.service.start()
      File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 98, in start
        self.assert_process_still_running()
      File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
        % (self.path, return_code)
    selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/chromedriver unexpectedly exited. Status code was: 127

Chromedriver version is correct.

I have no idea what is wrong here.

kjtn99
  • 51
  • 1
  • 8

2 Answers2

0

To avoid version based problems you can just use the latest version by downloading it at the start of your script. It then will be saved in cache for further use:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get('https://www.google.com/')
Jonas
  • 1,749
  • 1
  • 10
  • 18
  • Once again, should I install ChromeDriverManager in another new script? – kjtn99 Aug 09 '20 at 14:08
  • If you use another new script you need to add th line again. It then download the Driver you need and runs your programm – Jonas Aug 09 '20 at 14:46
0

In java normally set driver like below

    System.setProperty("webdriver.chrome.driver","chrome driver path");
    WebDriver driver = new ChromeDriver();
    driver.get("url");
Justin Lambert
  • 940
  • 1
  • 7
  • 13