Hello community,
I'm about 13hrs into trying to solve this puzzle. I'm trying to run a Python script that evokes Selenium for simple scraping. The script works on Windows, but I seem to be struggling with the chromedriver on the Pi.
System
- Raspberry Pi Zero W
- Raspbian GNU/Linus 11 (bullseye)
- Selenium 4.11.2
Install (and clean)
pip uninstall selenium
sudo apt purge --remove chromium-browser chromium chromium-chromedriver -y
sudo apt autoremove && sudo apt autoclean -y
sudo apt-get install chromium-chromedriver --yes
sudo apt-get install xvfb --yes
pip install PyVirtualDisplay xvfbwrapper selenium
Code
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1600, 1200))
display.start()
service = Service(executable_path='/usr/bin/chromedriver')
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(service=service, options=options)
driver.get("
https://www.google.com")
driver.close()
Command line
Error
Traceback (most recent call last):
File "/home/pi/samba_dir/tester.txt", line 18, in <module>
driver = webdriver.Chrome(service=service, options=options)
File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 53, in __init__
self.service.start()
File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 109, in start
self.assert_process_still_running()
File "/home/pi/.local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 122, in assert_process_still_running
raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/chromedriver unexpectedly exited. Status code was: -4
I confirmed that the chromedriver is indeed located at /usr/bin/chromedriver. I also changed the permissions on chromedriver to 755 (chmod 755 /usr/bin/chromedriver).
When I attempt to execute chromedriver from the commandline by entering ./chromedriver I recieve "Illegal instruction"
I would really appreciate an help anyone can offer.
My thanks.
Eric