Jiveloper

Mac OS WebDriverException: Message: 'chromedriver' executable needs to be in PATH 에러 해결 방법

by Jisight

Dev

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/common/service.py in start(self)
     71             cmd.extend(self.command_line_args())
---> 72             self.process = subprocess.Popen(cmd, env=self.env,
     73                                             close_fds=platform.system() != 'Windows',

~/opt/anaconda3/lib/python3.8/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    857 
--> 858             self._execute_child(args, executable, preexec_fn, close_fds,
    859                                 pass_fds, cwd, env,

~/opt/anaconda3/lib/python3.8/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1705                         err_msg = os.strerror(errno_num)
-> 1706                     raise child_exception_type(errno_num, err_msg, err_filename)
   1707                 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

During handling of the above exception, another exception occurred:

WebDriverException                        Traceback (most recent call last)
<ipython-input-5-be12b8104100> in <module>
      1 from selenium import webdriver
      2 
----> 3 browser = webdriver.Chrome()
      4 browser.get('http://naver.com' class="ansi-blue-fg">)

~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
     71             service_args=service_args,
     72             log_path=service_log_path)
---> 73         self.service.start()
     74 
     75         try:

~/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/common/service.py in start(self)
     79         except OSError as err:
     80             if err.errno == errno.ENOENT:
---> 81                 raise WebDriverException(
     82                     "'%s' executable needs to be in PATH. %s" % (
     83                         os.path.basename(self.path), self.start_error_message)

WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

MacOS Big Sur 11.4 버전에서 JupyterLab으로 셀레니움 예제 코드 실행 시 발생한 에러다. PATH 경로에 ChromeDriver를 이동시키면 해결된다. Default값은 /usr/local/bin이다.

 

만약 개발자를 확인할 수 없기 때문에 'chromedriver'을(를) 열 수 없습니다. 나타나면 아래처럼 해준다. 또한 chrome://version/ 를 통해서 크롬 버전 확인 후 https://chromedriver.chromium.org/downloads에서 같은 버전으로 설치해준다.

$ cd /usr/local/Caskroom/chromedriver/
$ 91.0.4472.114
$ xattr -d com.apple.quarantine chromedriver

 

 

블로그의 정보

Jiveloper

Jisight

활동하기