Reputation: 61
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
Upvotes: 6
Views: 17261
Reputation: 11
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'
Upvotes: 1
Reputation: 135
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
.
Upvotes: 5
Reputation: 843
At the moment Chrome Driver dont support ARM processors architecture anymore.
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=95322
Upvotes: 3