프로그래밍IDEPython

크롬드라이버 OSError: [Errno 8] Exec format error: 오류 해결방법(chromedriver-mac-x64/THIRD_PARTY_NOTICES.chromedriver)

맥북m1 Pro에서 잘 실행되던 크롬 드라이버에 대한 오류가 발생되었다. 오류 내용은 아래와 같은데…..맥OS업데이트 후 발생되는 문제로 생각된다.

Traceback (most recent call last):
  File "/Users/test/PycharmProjects/pythonProject1/main.py", line 283, in <module>
    driver = webdriver.Chrome(ChromeDriverManager().install())
  File "/Users/test/.conda/envs/pythonProject1/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Users/test/.conda/envs/pythonProject1/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/Users/test/.conda/envs/pythonProject1/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/test/.conda/envs/pythonProject1/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/Users/test/.wdm/drivers/chromedriver/mac64/131.0.6778.109/chromedriver-mac-x64/THIRD_PARTY_NOTICES.chromedriver'

그런데 왜 THIRD_PARTY_NOTICES.chromedriver이 실행되는것일까? chromedriver 파일이 실행되어야하는데 말이다.

아래 구글크롬랩 깃허브 사이트에서 맥arm-64용 크롬드라이버를 다운받았다.

https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json

애플에서 만든 cpu를 사용중이라면 아래 버전을 다운받으면 된다.

"platform": "mac-arm64",
"url": "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/mac-arm64/chrome-mac-arm64.zip"

크롬 드라이버를 다운로드 후 파이썬 코드에 경로를 지정하고 파이썬 코드 실행을 하였다.

import json
import math
import os
# import numpy
import random
import time
import urllib.parse
import urllib.request

from bs4 import BeautifulSoup
# import pandas
from numpy import long
from selenium import webdriver

....이상 생략
location = '/Users/test/Downloads/chromedriver/chromedriver'
driver = webdriver.Chrome(executable_path=location)
....이하 생략

보안문제로 실행되지 않고 팝업 하나 노출 후 오류코드가 로그창에 찍혔다.

  File "/Users/test/.conda/envs/pythonProject1/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 104, in start
    raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /Users/test/Downloads/chromedriver/chromedriver


이번엔 자동으로 설치된 폴더 경로의 크롬 드라이버 파일을 실행해보았다.

chrome_driver_path = '/Users/test/.wdm/drivers/chromedriver/mac64/131.0.6778.109/chromedriver-mac-x64/chromedriver'

driver = webdriver.Chrome(executable_path=chrome_driver_path)

오류 내용이 또 바뀌었다.

 raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home


오류 해결을 위한 권한 부여

파이참 개발툴을 기준으로 기록해둔다.

파이참 툴 하단에 터미널 탭을 클릭 후 chromedriver에 실행권한을 부여해준 후 실행하면 해결된다.

명령어를 실행하려면 맥북 로그인 계정의 비밀번호를 입력해주어야 한다.

sudo chmod +x /Users/test/.wdm/drivers/chromedriver/mac64/131.0.6778.109/chromedriver-mac-x64/chromedriver

Password:



2025.04.13. 크롬드라이버 135버전부터는 위 명령어도 먹히지 않는다.

맥OS업데이트 발생하는 문제인 것 같다.

해결방법은 UI에서 해결하자

  1. Mac에서 Apple 메뉴 > 시스템 설정
  2. 사이드바에서 개인정보 보호 및 보안을 클릭
  3. 스크롤을 내리면
  4. 보안 탭에서 “Mac을 보호하기 위해 ‘chromedriver’을(를) 차단해습니다.
  5. ‘그래도 허용’를 클릭.
  6. 파이썬에서 다시 크롤링시작해보면 “chromedirver’을(를) 열겠습니까? 팝업창이 열리면 “그래도 열기”를 클릭한다.
  7. 로그인 암호를 입력한 다음 확인을 클릭하십시오.

error: Content is protected !!