본문 바로가기
카테고리 없음

셀레니움 Selenium error 대처 : no module , webdriver path

by 이승보 2021. 2. 22.
728x90

 

www.youtube.com/watch?v=1b7pXC1-IbE&ab_channel=%EC%A1%B0%EC%BD%94%EB%94%A9JoCoding

이 영상을 통해서 처음 python과 셀레니움을 접했는데..

VSCode 에서 웹드라이버 경로를 못찾아줘서 너무나 난감.....혼자 끙끙끙 대고 여러 대처 방법들을 해봤으나 안되다가

아래의 방법으로 나는 해결.

다른 해결 방법들은 검색하면 중복적으로 많이 나오던데 나는 이걸로 해결했다.

I see the discussions still talk about the old way of setting up chromedriver by downloading the binary and configuring the path manually.

This can be done automatically using webdriver-manager

pip install webdriver-manager

Now the above code in the question will work simply with below change,

from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(ChromeDriverManager().install())

The same can be used to set Firefox, Edge and ie binaries.

#I see the discussions still talk about the old way of setting up chromedriver by downloading the binary and configuring the path manually.
#This can be done automatically using webdriver-manager

pip install webdriver-manager
#Now the above code in the question will work simply with below change,

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
#The same can be used to set Firefox, Edge and ie binaries.

stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path

아래는 내가 마주한 에러메시지들.

Traceback (most recent call last):
  File "/Users/sb/ㅇㅅㅂ/WEB/ex_crawling/selenium/google.py", line 2, in <module>
    from selenium import webdriver
ImportError: No module named selenium
(selenium) appleui-MacBookAir:selenium sb$ python google.py
Traceback (most recent call last):
  File "/Users/sb/ㅇㅅㅂ/WEB/ex_crawling/selenium/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'Users/sb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sb/ㅇㅅㅂ/WEB/ex_crawling/selenium/google.py", line 5, in <module>
    driver = webdriver.Chrome(executable_path= r"Users/sb")
  File "/Users/sb/ㅇㅅㅂ/WEB/ex_crawling/selenium/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/Users/sb/ㅇㅅㅂ/WEB/ex_crawling/selenium/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'sb' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
728x90
반응형

댓글