skip to Main Content

This code throws an exception:

from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('https://www.google.com')
time.sleep(10)

Here’s the backtrace:

Traceback (most recent call last):
  File "/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/common/selenium_manager.py", line 134, in run
    completed_proc = subprocess.run(args, capture_output=True)
  File "/usr/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/common/linux/selenium-manager'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/common/driver_finder.py", line 38, in get_path
    path = SeleniumManager().driver_location(options) if path is None else path
  File "/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/common/selenium_manager.py", line 103, in driver_location
    output = self.run(args)
  File "/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/common/selenium_manager.py", line 140, in run
    raise WebDriverException(f"Unsuccessful command executed: {command}") from err
selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: /home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --output json


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/orangepi/Downloads/from selenium import webdriver.py", line 3, in <module>
    driver = webdriver.Chrome()
  File "/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 49, in __init__
    self.service.path = DriverFinder.get_path(self.service, options)
  File "/home/orangepi/.local/lib/python3.10/site-packages/selenium/webdriver/common/driver_finder.py", line 41, in get_path
    raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

I don’t know where I am going wrong with this: chrome is installed; I tried a few tutorials and no success.

2

Answers


  1. Selenium search for chrome driver in your path variables, you can add it manually or set the driver in your code.

    path var

    This issue can generally be fixed easly by downloading chromium driver https://developer.chrome.com/docs/chromedriver/downloads?hl=fr

    Then you can specify the path of this driver in the code or in your env var

    driver = webdriver.Chrome(executable_path=r'C:pathtochromedriver.exe')
    

    Final code :

    from selenium import webdriver
    
    # Optional argument : if not specified WebDriver will search your system PATH environment variable for locating the chromedriver
    driver = webdriver.Chrome(executable_path=r'C:pathtochromedriver.exe')
    driver.get('https://www.google.co.in')
    print("Page Title is : %s" %driver.title)
    driver.quit()
    
    Login or Signup to reply.
  2. The OP indicated that they needed to use Chromium instead of Chrome on AMD64.

    (I’m posting this as a placeholder for an answer from them; please feel free to delete this if they do.)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search