selenium、python和chrome出现多个错误

2024-09-30 14:21:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我找不到此错误的解决方案,代码非常简单,但我无法修复它,请帮助

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()
driver.get("www.google.com")
driver.close()

我试过用geckodriver,还有各种各样的路径,但是没有改变

Traceback (most recent call last):
File "/home/lautaro/.local/lib/python3.8/site- 
packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lautaro/.local/lib/python3.8/site- 
packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/lautaro/.local/lib/python3.8/site- 
packages/selenium/webdriver/common/service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' 
executable needs to be in PATH. Please see 
https://sites.google.com/a/chromium.org/chromedriver/home

Tags: inpyselfhomelibpackageslocaldriver