相关文章推荐
安静的苦瓜  ·  selenium获取元素文本值·  1 月前    · 
博学的警车  ·  GEE学习笔记 ...·  1 年前    · 
发呆的单车  ·  qt C++ ...·  1 年前    · 
精明的饺子  ·  Troubleshoot form ...·  1 年前    · 
from selenium import webdriver driver = webdriver.Chrome(executable_path = ' chromedriver.exe' )
error :
Traceback (most recent call last): File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py" , line 72 , in start self.process = subprocess.Popen(cmd, env=self.env, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 951 , in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 1420 , 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: self.service.start() File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\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 PS D:\codes> > & C:/Users/eskandarijoon/AppData/Local/Programs/Python/Python39/python.exe d:/codes/slnm/main.py Traceback (most recent call last): File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py" , line 72 , in start self.process = subprocess.Popen(cmd, env=self.env, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 951 , in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 1420 , 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: File " d:\codes\slnm\main.py" , line 3 , in <module> driver = webdriver.Chrome(executable_path = r ' D:\codes\slnm(1)\chromedriver.exe' ) File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py" , line 73 , in __init__ self.service.start() File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\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 PS D:\codes> & C:/Users/eskandarijoon/AppData/Local/Programs/Python/Python39/python.exe d:/codes/slnm/main.py Traceback (most recent call last): File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py" , line 72 , in start self.process = subprocess.Popen(cmd, env=self.env, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 951 , in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 1420 , 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: File " d:\codes\slnm\main.py" , line 3 , in <module> driver = webdriver.Chrome(executable_path = r ' D:\codes\slnm(1)\chromedriver.exe' ) File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py" , line 73 , in __init__ self.service.start() File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\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 PS D:\codes> & C:/Users/eskandarijoon/AppData/Local/Programs/Python/Python39/python.exe d:/codes/slnm/main.py Traceback (most recent call last): File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py" , line 72 , in start self.process = subprocess.Popen(cmd, env=self.env, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 951 , in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 1420 , 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: File " d:\codes\slnm\main.py" , line 2 , in <module> driver = webdriver.Chrome(executable_path = ' chromedriver.exe' ) File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py" , line 73 , in __init__ self.service.start() File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\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 PS D:\codes> & C:/Users/eskandarijoon/AppData/Local/Programs/Python/Python39/python.exe d:/codes/slnm/main.py Traceback (most recent call last): File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py" , line 72 , in start self.process = subprocess.Popen(cmd, env=self.env, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 951 , in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\subprocess.py" , line 1420 , 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 " d:\codes\slnm\main.py" , line 2 , in <module> driver = webdriver.Chrome(executable_path = ' chromedriver.exe' ) File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py" , line 73 , in __init__ self.service.start() File " C:\Users\eskandarijoon\AppData\Local\Programs\Python\Python39\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
What I have tried:
from selenium import webdriver driver = webdriver.Chrome(executable_path = ' chromedriver.exe' ) 这个解决方案确实有效,但由于本人时常粗心大意,因此提供一个无脑的解决方案。
不是自己编写的代码的话,有一种可能——自己的浏览器驱动与代码中的驱动并不一致。
因此修改代码中的浏览器驱动即可。
weather_web = webdriver.Chrome()
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •