• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Python, SQL 게시판 파이썬에서 셀레니움 실행 오류 질문입니다.

파이썬에서 셀레니움 실행 오류 질문입니다.

  • 이 주제에는 8개 답변, 2명 참여가 있으며 NB1 년, 5 월 전에 전에 마지막으로 업데이트했습니다.
9 글 보임 - 1 에서 9 까지 (총 9 중에서)
  • 글쓴이
  • #110467

    NB
    참가자
    셀레니움 4.16.0 버전 오류나서 3.14.1 버전도 다운받아서 돌려봤는데 실행이 되지 않습니다.
    현재 크롬드라이버 120버전 쓰고 있습니다.
    
    
    3.14.1 버전 사용해서
    
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    driver = webdriver.Chrome('chromedriver.exe')
    driver.get('https://instagram.com')
    
    이 명령어 돌릴 시 아래와 같은 메세지 출력되고 인터넷 창이 열리지 않습니다.
    인터넷 돌아다니며 해결법 찾아봤는데 도무지 해결되질 않네요.
    혹시 방법있을까요?
    
    
    
    Traceback (most recent call last):
    File "C:\Users\NoteA\OneDrive\바탕 화면\Practice\app.py", line 5, in <module>
    driver = webdriver.Chrome()
    ^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session 
    response = self.execute(Command.NEW_SESSION, parameters)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
    response = self.command_executor.execute(driver_command, params)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 376, in execute 
    return self._request(command_info[0], url, body=data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 399, in _request 
    resp = self._conn.request(method, url, body=body, headers=headers) 
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\_request_methods.py", line 118, in request
    return self.request_encode_body(
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\_request_methods.py", line 217, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\poolmanager.py", line 433, in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme) 
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\poolmanager.py", line 304, in connection_from_host
    return self.connection_from_context(request_context)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\poolmanager.py", line 329, in connection_from_context
    return self.connection_from_pool_key(pool_key, request_context=request_context)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\poolmanager.py", line 352, in connection_from_pool_key
    pool = self._new_pool(scheme, host, port, request_context=request_context)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\poolmanager.py", line 266, in _new_pool
    return pool_cls(host, port, **request_context)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 196, in __init__
    timeout = Timeout.from_float(timeout)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\timeout.py", line 190, in from_float
    return Timeout(read=timeout, connect=timeout)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\timeout.py", line 119, in __init__
    self._connect = self._validate_timeout(connect, "connect")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\timeout.py", line 156, in _validate_timeout
    raise ValueError(
    ValueError: Timeout value connect was <object object at 0x0000021127EE8610>, but it must be an int, float or None.
    
    #110499

    codingapple
    키 마스터
    셀레니움 지웠다가 4.11.2버전 한번 설치해봅시다
    #110501

    NB
    참가자
    3.14.1 버전 언인스톨 후 4.11.2 버전 인스톨하여 실행하니 아래와 같은 문구 출력됩니다.
    
    
    Traceback (most recent call last):
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 38, in get_path
        path = SeleniumManager().driver_location(options) if path is None else path
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 71, in driver_location
        browser = options.capabilities["browserName"]
                  ^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'str' object has no attribute 'capabilities'
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "C:\Users\NoteA\OneDrive\바탕 화면\Practice\app.py", line 5, in <module>
        driver = webdriver.Chrome('chromedriver.exe')
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
        super().__init__(
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 51, in __init__
        self.service.path = DriverFinder.get_path(self.service, options)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 40, in get_path        
        msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."
                                             ^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'str' object has no attribute 'capabilities'
    
    
    #110548

    codingapple
    키 마스터
    webdriver.Chrome('chromedriver.exe')를 webdriver.Chrome() 로 써봅시다
    #110556

    NB
    참가자
    코드 바꿔서 실행했습니다.
    하는 김에 크롬드라이버도 권장버전 맞는지 확인하고 돌렸는데도 계속 오류가 납니다.
    
    Traceback (most recent call last):
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 38, in get_path
        path = SeleniumManager().driver_location(options) if path is None else path
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 90, in driver_location
        output = self.run(args)
                 ^^^^^^^^^^^^^^
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 138, in run 
        raise WebDriverException(f"Unsuccessful command executed: {command}.\n{result}{stderr}")
    selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --output json.
    {'code': 69, 'message': 'Driver unavailable: Driver path: ', 'driver_path': '', 'browser_path': ''}
    The above exception was the direct cause of the following exception:
    Traceback (most recent call last):
      File "C:\Users\NoteA\OneDrive\바탕 화면\Practice\app.py", line 5, in <module>
        driver = webdriver.Chrome()
                 ^^^^^^^^^^^^^^^^^^
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__    
        super().__init__(
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 51, in __init__  
        self.service.path = DriverFinder.get_path(self.service, options)     
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^     
      File "C:\Users\NoteA\AppData\Local\Programs\Python\Python312\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 41, in get_path
        raise NoSuchDriverException(msg) from err
    selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
    #110566

    codingapple
    키 마스터
    크롬드라이버 압축푼곳에 파이썬파일도 같이 넣고 나서 파이썬파일 실행해봅시다
    #110603

    NB
    참가자
    이미 강의 영상대로 같은 파일에 chromedriver.exe파일이랑 app.py 파이썬 파일이랑 같이 두고 실행한 상태입니다.
    혹시 python.exe파일도 같은 폴더에 넣고 코드 실행해보라는 말씀이신가요?
    #110623

    codingapple
    키 마스터
    근데 4.10버전 이상이면 크롬드라이버 다운안받아도 잘되는거같군요 
    onedrive 폴더 바깥에다가 만들어서 밑에 코드넣고 테스트해봅시다
    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    service = Service()
    options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(service=service, options=options)
    
    
    #110638

    NB
    참가자
    파일을 통째로 onedrive 안쪽에서 빼서 만드니까 잘 작동합니다.
    답변 정말 감사합니다.
    
    
    
9 글 보임 - 1 에서 9 까지 (총 9 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠