6

So I'm trying to run Selenium on my raspberry pi using Chromium and for some reason I can't get my python file to compile. I keep getting the following error:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver.exe'))
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/service.py", line 75, in start
os.path.basename(self.path), docs_msg)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Here is the python code I'm trying to run:

from selenium import webdriver
import os

driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver'))

driver.get("http://www.google.com")

driver.quit()

Any ideas?

Update

After removing the '.exe' at the end of chromedriver, it now produces the following error:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    driver = webdriver.Chrome(os.path.expanduser('/usr/bin/chromedriver'))
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.46.0-py2.7.egg/selenium/webdriver/chrome/service.py", line 68, in start
self.service_args, env=env, stdout=PIPE, stderr=PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error
7
  • You need to provide it with a chromedriver binary for linux, not chromedriver.exe. Commented Jul 2, 2015 at 16:45
  • I took off the '.exe' at the end of the chromedriver file. That being said, I can assure you that I am using the binary specifically made for linux. Commented Jul 2, 2015 at 16:59
  • Removing the .exe from the end of the filename does not make it less windows executable. Follow the link I've provided, download the one for linux and use. Commented Jul 2, 2015 at 18:02
  • Like I mentioned in my previous comment. I've already downloaded the chromedriver for linux. I've been using it this entire time. The only reason I had '.exe' at the end of the file was because I thought the entire filename was supposed to be written out completely. Sorry for the confusion. Commented Jul 2, 2015 at 18:08
  • 1
    From the command line, on the PI, try running /usr/bin/chromedriver. What do you get? Commented Jul 2, 2015 at 18:43

3 Answers 3

5

Ubuntu has builds of chromium-chromedriver as .deb files for armhf.

On launchpad, therefore, you can find chromium-chromedriver armhf builds available for download. Just download the latest version, and since they have no dependencies, you can install by running dpkg -i chromium-chromedriver_58.0.3029.96-0ubuntu0.14.04.1174_armhf.deb. Then chromedriver will be available in /usr/lib/chromium-browser/chromedriver.

Sign up to request clarification or add additional context in comments.

3 Comments

This didn't work for me. After downloading the geckodriver v0.19.1 tarball and moving geckodriver to /usr/local/bin/, the command geckodriver -b /usr/bin/firefox --webdriver-port 45753 yields the error geckodriver: /lib/arm-linux-gnueabihf/libc.so.6: version 'GLIBC_2.18' not found (required by geckodriver)
I gave instructions for chromedriver, not geckodriver.
This worked for me and should be the accepted answer. The key is ensuring the chromedriver version matches the version of Chromium installed on the pi. In my case, I had to update Chromium. Once that was done, as long as I passed the /usr/lib/chromium-browser/chromedriver path when initializing the driver, everything worked great.
3

At the moment Chrome Driver dont support ARM processors architecture anymore.

https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=95322

Comments

1

Update 2023: At this moment in time, chromium web driver for Raspberry Pi is available from repo via:

sudo apt install chromium-chromedriver

The driver will be at /usr/lib/chromium-browser/chromedriver

https://ivanderevianko.com/2020/01/selenium-chromedriver-for-raspberrypi

I successfully ran the following code under Bullseye 32-bit, slightly updated from original test program due to syntax change on find_element:

import time
from selenium import webdriver

driver = webdriver.Chrome()  # Optional argument, if not specified will search path.
driver.get('http://www.google.com/');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element("name", "q")
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

Original chromium.org test that no longer works, deprecated: https://sites.google.com/a/chromium.org/chromedriver/getting-started

Info on updated syntax: Selenium - Python - AttributeError: 'WebDriver' object has no attribute 'find_element_by_name'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.