2

введите сюда описание изображения Добры день. Я пытаюсь использовать chromedriver с библиотекой на selenium на python. Мне выдает ошибку, что нету драйвера, хотя он есть. Моя OC - Linux mint.

import os
from selenium import webdriver

def main():
    driver = webdriver.Chrome("/usr/bin/chromedriver")
    driver.get('google.com')


if __name__ == "__main__":

main()

Ошибка

Traceback (most recent call last):
  File "/var/data/python/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/chromedriver': '/usr/bin/chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hacker/Desktop/pycharmprojects/parser1000rub/main.py", line 11, in <module>
    main()
  File "/home/hacker/Desktop/pycharmprojects/parser1000rub/main.py", line 6, in main
    driver = webdriver.Chrome("/usr/bin/chromedriver")
  File "/var/data/python/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/var/data/python/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1

1 ответ 1

1

Просто следуйте инструкции в тексте самой ошибки:

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

Т.е. по указанной ссылке скачайте драйвер и путь к нему (достаточно папки) добавьте в переменную среды PATH

Или же вручную укажите путь к драйверу в классе через параметр executable_path:

driver = webdriver.Chrome(executable_path="<Путь до драйвера>")

Источник

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.