【发布时间】:2020-07-24 14:52:38
【问题描述】:
我的代码中出现以下错误:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py",
line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\user\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\user\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
我尝试更改 PATH 变量,更改 chromedriver 路径无济于事。有趣的是,这个错误只是有时会发生,但我还没有找到一个模式。这是我的 chromedriver 定义:
options = Options()
options.headless = True
options.add_argument('--log-level=3')
chromepath = str(Path(os.getcwd()).parent) + r'\chromedriver.exe'
driver = webdriver.Chrome(chromepath, options=options)
【问题讨论】:
-
如果路径中有chromedriver.exe,我认为不需要引用chromepath。
标签: python selenium web-scraping selenium-chromedriver