我是编码新手,只是不明白这个错误代码的含义



我最近才开始使用Python 3进行编码。我不知道如何表达我想问的问题,因为我不理解返回的这些错误的任何部分。

Traceback (most recent call last):
File "C:UsersLiam McAuleyAppDataLocalProgramsPythonPython38libsite-packagesseleniumwebdrivercommonservice.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:UsersLiam McAuleyAppDataLocalProgramsPythonPython38libsubprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:UsersLiam McAuleyAppDataLocalProgramsPythonPython38libsubprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:UsersLiam McAuleyAppDataLocalProgramsPythonPython38shrek.py", line 13, in <module>
driver = webdriver.Chrome('chromedriver.exe')
File "C:UsersLiam McAuleyAppDataLocalProgramsPythonPython38libsite-packagesseleniumwebdriverchromewebdriver.py", line 73, in __init__
self.service.start()
File "C:UsersLiam McAuleyAppDataLocalProgramsPythonPython38libsite-packagesseleniumwebdrivercommonservice.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

有人能帮忙吗?

您的系统找不到chromerdriver可执行文件。当您使用Windows时,我建议使用可执行文件的完整路径定义:

driver = webdriver.Chrome(executable_path="C:UsersLiam McAuleypathtoactualchromedriver.exe")

或者,您可以通过在命令提示符中键入此命令将chromedriver.exe添加到您的路径中(确保您以管理员身份运行!(

setx CHROMEDRIVER=C:UsersLiam McAuleypathtoactualchromedriver.exe

通过读取跟踪,似乎有两件事出了问题。第一个问题是python似乎找不到您指定的文件,所以请检查您的路径。第二个问题是您的PATH上可能没有chromedriver。如果你使用的是windows,你可以通过环境变量选项卡将其添加到路径中。你也可以按照这里的步骤

Selenium试图访问chromdriver,这是一个用于执行的Web驱动程序

driver = webdriver.Chrome('chromedriver.exe')

为了使用chromedriver,它必须在路径上。你可以在这里买到彩色打印机。至于如何将内容添加到路径,您可以临时使用SETX

setx CHROMEDRIVER=path/to/chromedriver.exe

或者你可以为驱动程序创建一个文件夹,然后按照这里的说明将该文件夹永久添加到路径

相关内容

最新更新