Issue with Selenium and webdriver
Asked Answered
D

12

11

I'm trying to use the webdriver and Selenium, it was working fine a couple days ago but I'm currently facing this issue where I receive this error: [Errno 8] Exec format error: '/Users/[USER]/.wdm/drivers/chromedriver/mac64/127.0.6533.72/chromedriver-mac-arm64/THIRD_PARTY_NOTICES.chromedriver'

Here is the relevant portion of code that relates to this:

            options = webdriver.ChromeOptions()
            options.add_argument("--headless")
            options.add_argument("--no-sandbox")
            options.add_argument("--disable-dev-shm-usage")
            d_path = ChromeDriverManager().install()
            driver = webdriver.Chrome(service=Service(d_path), options=options)

I have tried to manually change the d_path by replacing the 'THIRD_PARTY_NOTICES.chromedriver' with 'chromedriver' but that in itself also does not work.

Dartmouth answered 24/7, 2024 at 17:43 Comment(1)
This question is similar to: THIRD_PARTY_NOTICES.chromedriver - Exec format error - undetected_chromedriver. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.Vidovic
J
14

Maybe is not the best solution, but, I solved it updating/installing a clean version of the webdriver-manager (min 4.0.2 version):

pip uninstall webdriver-manager
pip install webdriver-manager

And after it, removing the last entry of the drivers.json file (/Users/xxxx/.wdm/drivers.json):

"mac64_chromedriver_127.0.6533.72_for_127.0.6533": {
    "timestamp": "26/07/2024",
    "binary_path": "/Users/Alejandro/.wdm/drivers/chromedriver/mac64/127.0.6533.72/chromedriver-mac-x64/THIRD_PARTY_NOTICES.chromedriver"
}
Jdavie answered 26/7, 2024 at 8:27 Comment(1)
This fixes the issue. Though, does anybody know why pip install -U web driver-manager doesn't seem to work?Allusive
O
5

I also got the same issue, was banging my head around it. Trying to install specific versions.

Ultimately the fix was to update webdriver-manager package to v4.0.2

They have fixed the issue so that correct file is chosen as driver.

Op answered 26/7, 2024 at 7:10 Comment(1)
Don't forget to delete ~/.wdm directory.Swerve
R
4

For webdriver_manager/core/driver_cache.py apply this patch, will solve the issue:

--- driver_cache.py.orig    2024-07-24 21:39:13.474007824 +0200
+++ driver_cache.py 2024-07-24 21:33:11.640867288 +0200
@@ -68,6 +68,8 @@
         for f in files:
             if 'LICENSE' in f:
                 continue
+            if 'THIRD_PARTY_NOTICES' in f:
+                continue
             if driver_name in f:
                 return f

WDM takes THIRD_PARTY_NOTICES.chromedriver file in the archive as the chromedriver binary intead of the file chromedriver, and this cause the error.

Regent answered 24/7, 2024 at 19:52 Comment(3)
yes, this is the fix. One of the stupidest bugs i have spend a day on.Op
It worked for me too. Get an up vote to help who will arrive here. :)Curmudgeon
I believe it’s better to rename the file in WDM to THIRD_PARTY.chromedriver rather than modifying the code in site-packages. Changing code in site-packages can be risky due to potential unintended side effects. Direct modifications may cause the package to behave unpredictably, disrupting its internal logic. Additionally, if you upgrade the package, your changes could be lost, and the package might revert to its original state. Modifying files in site-packages could also lead to dependency conflicts, as other packages might rely on the original behavior.Amboina
P
1
driver_path = ChromeDriverManager().install()
if not driver_path.endswith("chromedriver.exe"):
    driver_dir = os.path.dirname(driver_path)
    driver_path = os.path.join(driver_dir, "chromedriver.exe")

I also had an issue and found that current 127.0.6533.72 version contains THIRD_PARTY_NOTICES.chromedriver file and driver_path select this. So please reselect the path so that it chooses the chromedriver.exe file.

Precocious answered 25/7, 2024 at 13:37 Comment(2)
This appears to be a bug in selenium that returns the path to a 3rd party notices text file instead of the chromedriver.exe file. The solution by ai kerin here is a clean workaround until they get it fixed.Lucilius
What do you mean by "driver_path select this"? I attempted to clarify your post, but this part wasn't clear to me.Culminate
S
1

I also suffered from this problem too. I'm on a Mac and I opened the drivers.json file in the .wdm directory and deleted "THIRD_PARTY_NOTICES" from the last entry.

"mac64_chromedriver_127.0.6533.72_for_127.0.6533": {
        "timestamp": "26/07/2024",
        "binary_path": "/Users/admin/.wdm/drivers/chromedriver/mac64/127.0.6533.72/chromedriver-mac-x64/chromedriver"
}

I think this is a temporary fix but it works fine now.

Swerve answered 26/7, 2024 at 1:45 Comment(0)
G
1

Worked for me by updating the webdriver to v4.0.2 and modifying the /Users/ahsanbilal/.wdm/drivers.json file.

Remove the most recent one:

"mac64_chromedriver_127.0.6533.72_for_127.0.6533": {
    "timestamp": "30/07/2024",
    "binary_path": "/Users/ahsanbilal/.wdm/drivers/chromedriver/mac64/127.0.6533.72/chromedriver-mac-arm64/THIRD_PARTY_NOTICES.chromedriver"
}
Glede answered 30/7, 2024 at 10:37 Comment(0)
G
1

easy fix > Delete this /Users/[USER]/.wdm

Guacharo answered 9/8, 2024 at 7:57 Comment(1)
Yes, this worked perfectly.Omidyar
L
0

I am also suddenly having this issue. It seems to be related to the new Chromedriver release, but can't pin down what. The only other thread I've found is Selecting default search engine is needed for Chrome version 127 but unfortunately that doesn't help my case. Maybe it will help you.

As a workaround, you could try downloading a Chromedriver executable and pointing to that instead of using webdriver-manager.

Please let me know if you find a better workaround

Lermontov answered 24/7, 2024 at 18:45 Comment(1)
The answer given by @zhivago-dr is working well.Curmudgeon
L
0

I am also facing this issue with no certainty on what is actually broken.

However I do have a temporary workaround that might help until it has been solved

All I did here was just explicitly entered the path to the driver. You would need to update the executable_path based on where your chromedriver binary is located in.

# environment.py

executable_path = "../wdm/drivers/chromedriver/mac64/127.0.6533.72/chromedriver-mac-arm64 chromedriver"
    context.driver = webdriver.Chrome(
        service=ChromeService(executable_prath=executable_path), options=options
    )

For cases for your CI pipeline (if you run your tests there), I'm not sure if it would work because I have not verified it on my own. But you could give the same workaround a shot. I've added shell script snippet to fetch the latest version of chromedriver and installing it to /usr/local/bin Here, the executable_path would be "usr/local/bin/chromedriver"

# Get the latest stable version of ChromeDriver
RESPONSE=$(curl -sSL "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
LATEST_STABLE_VERSION=$(echo "$RESPONSE" | grep -oP '"Stable":\s*\{\s*"channel":.*?"version":\s*"\K[^"]+')

# Download ChromeDriver
CHROMEDRIVER_URL="https://storage.googleapis.com/chrome-for-testing-public/${LATEST_STABLE_VERSION}/linux64/chromedriver-linux64.zip"
curl -sSL "$CHROMEDRIVER_URL" -o /tmp/chromedriver_linux64.zip

# Install ChromeDriver
unzip /tmp/chromedriver_linux64.zip -d /usr/local/bin
Lorinalorinda answered 25/7, 2024 at 6:23 Comment(0)
S
0

The following fixed it for me.

  1. Download the appropriate chromedriver.exe: (for me "Stable", mac-arm64) https://googlechromelabs.github.io/chrome-for-testing/#stable

  2. Copy this chromedriver.exe to the folder where my Python script exists. selenium - chromedriver executable needs to be in PATH (see "An answer from 2020.")

  3. Update Python code by disabling the ChromeDriverManager and replacing it with path where chromedriver.exe was copied. I tried referencing it in the /usr/local/bin folder and no luck. But it liked it in the same folder as the Python script.

#driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

driver = webdriver.Chrome("/mypath/chromedriver")

  • where mypath is the exact path of my Python script

I tried the other solutions above, but unfortunately none worked for me exactly. In my case I am using Python 3.11.7, Selenium 4.9.1, Chrome v127 on a Mac Mini 2023. Firefox caused me issues, but Chrome would always work. Later versions of Selenium beyond 4.9.1 had caused issues with me pulling data from the web form I am using. So I am always reluctant to update Selenium this way. For the past year, this ChromeDriverManager worked very well. But this morning all my Python scripts using Selenium quit working due to this issue. The error message stated that post Chrome 127.0.6533.73 update, it was now looking for this THIRD_PARTY_NOTICES.chromedriver file instead of the actual chromedriver file both located in the same folder. So something got goofed up post Chrome v127 update globally. I reported it to Google as well. Hope this helps, RG

Songwriter answered 26/7, 2024 at 0:28 Comment(1)
Update: as others noted here updating from Webdriver-Manager 4.0.1 to 4.0.2 seems to fix this issue as it did for me (I'm still keeping the other option as a long-term backup). In case you're running on Mac like I am, Apple will probably try to quarantine the chromedrive.exe if it's being launched with some sort of scheduler. If so, remember to do the following one-time in Terminal so it can trust chromedriver.exe: xattr -d com.apple.quarantine <path>/chromedriverSongwriter
M
0

Workaround on kali linux (should be ok for ubuntu or other distros as well i hope)

Step 1: delete the file THIRD_PARTY_NOTICES.chromedriver

Step 2: Modify the line in drivers.json so it looks like this:

"linux64_chromedriver_127.0.6533.72_for_127.0.6533": {
        "timestamp": "28/07/2024",
        "binary_path": "/home/user/.wdm/drivers/chromedriver/linux64/127.0.6533.72/chromedriver-linux64/chromedriver"
    }
Mosora answered 28/7, 2024 at 13:0 Comment(0)
C
0

I had the same issue with several python/selenium scripts.

 service = ChromeService(ChromeDriverManager().install())

was prefixing chromedriver.exe path with 'THIRD_PARTY_NOTICES'. I replaced that statement with these four lines of code to get the correct path:

chrome_install = ChromeDriverManager().install()
folder = os.path.dirname(chrome_install)
chromedriver_path = os.path.join(folder, "chromedriver.exe")
service = ChromeService(chromedriver_path)

and the jobs work again, for now..

Cressida answered 4/8, 2024 at 10:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.