为什么在使用硒chromedriver时会发生此错误?

时间:2020-04-27 14:54:00

标签: selenium-chromedriver

C:\ Users \ abhi1702 \ Desktop \ Selenium \ venv \ Scripts \ python.exe

C:/Users/abhi1702/Desktop/selenium/app.py
Traceback (most recent call last):
  File "C:\Users\abhi1702\Desktop\selenium\venv\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\abhi1702\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\abhi1702\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "C:/Users/abhi1702/Desktop/selenium/app.py", line 5, in <module>
    chrome= webdriver.Chrome(executable_path='Users\abhi1702\Desktop\chromedriver\chromedriver.exe')
  File "C:\Users\abhi1702\Desktop\selenium\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\abhi1702\Desktop\selenium\venv\lib\site-packages\selenium\webdriver\common\service.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

1 个答案:

答案 0 :(得分:0)

答案可能在您的帖子中:

Message: 'chromedriver.exe' executable needs to be in PATH

因此,请尝试将chromedriver.exe添加到系统变量PATH中。

对于Windows,打开系统属性-环境变量-并修改系统变量“ PATH”:单击编辑,添加带有chromedriver.exe路径的新条目,例如: C:\ drivers \ chromedriver.exe