0

I have a raspberry-pi running linux-server as platform. Therefore there is no GUI and I execute all my tasks through terminal by SSH-ing into the Pi. Platform details:

uname -a

>> Linux ubuntu 5.4.0-1080-raspi #91-Ubuntu SMP PREEMPT Thu Jan 19 09:35:03 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

Chromium [No issues here]

I have installed Chromium through snap.

chromium --version
>> Chromium 109.0.5414.119 snap

I am able to run chromium, navigate to a website, and take a snapshot

chromium --headless --disable-gpu --screenshot https://www.wikipedia.com

>> 0215/140750.965255:WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable.
[0215/140752.998408:WARNING:sandbox_linux.cc(385)] InitializeSandbox() called with multiple threads in process gpu-process.
[0215/140802.665622:INFO:headless_shell.cc(223)] 84646 bytes written to file screenshot.png

Chromedriver [Issues]

I downloaded chromedriver this way

wget https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip

And moved Chromedriver to the applications folder after unzipping

I get this error when trying to get chromedriver version, let alone run it

chromedriver --version
>> bash: /usr/local/bin/chromedriver: cannot execute binary file: Exec format error

My Python Script [Issues]

Here is the script I want to be able to run finally

import selenium
from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--disable-gpu")
driver = webdriver.Chrome(options=options)
driver.get("https://www.wikipedia.com")
driver.save_screenshot("proof.png")

This is the error I get when I try to run it

python3 test.py

>> OSError: [Errno 8] Exec format error: 'chromedriver'

What I've Tried already

Using chromedriver directly through ChromeDriverManager

import selenium
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--disable-gpu")
driver = webdriver.Chrome(service=Service(ChromeDriverManager(path=".", chrome_type=ChromeType.CHROMIUM).install()), options=options)
driver.get("https://www.wikipedia.com")
driver.save_screenshot("proof.png")

The error

OSError: [Errno 8] Exec format error: './.wdm/drivers/chromedriver/linux64/109.0.5414/chromedriver'

Checking file permissions

Made sure file has execute permissions

ls -l /usr/local/bin/chromedriver

>> -rwxr-xr-x 1 ubuntu ubuntu 20427216 Sep  8  2021 /usr/local/bin/chromedriver
Aakash Dusane
  • 388
  • 4
  • 17
  • 1
    Your `chromedriver` is likely compiled for `x86_64` architecture. Have you tried `sudo apt-get install chromium-chromedriver`? – Alexey R. Feb 15 '23 at 15:32
  • @AlexeyR. I don't know why I didn't start with this. It helped. Spent another few hours tacking a resulting problem I was able to address using this solution https://stackoverflow.com/a/22735763/10057842 Thanks! – Aakash Dusane Feb 16 '23 at 08:29

1 Answers1

1

As you are having a raspberry-pi running linux-server as platform with Chromium 109.0.5414.119 you need to use ChromeDriver of:

  • Version 109.0
  • Linux compatible format i.e. chromedriver_linux64.tar.gz

Your effective line of code will be:

wget https://chromedriver.storage.googleapis.com/109.0.5414.74/chromedriver_linux64.tar.gz
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    This was basically it. I followed alexeyR's solution from the comments which essentially handles the `chromuim-browser` and `chromedriver` installs at the same time. Thanks! – Aakash Dusane Feb 16 '23 at 08:33