driver
11
if
__name__
==
'
__main__
'
:
12
base_driver()
报错信息:
1 Traceback (most recent call last):
2 File "E:\练习项目代码\project--python\data_system\venv\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
3 self.process = subprocess.Popen(cmd, env=self.env,
4 File "D:\software\python\lib\subprocess.py", line 854, in __init__
5 self._execute_child(args, executable, preexec_fn, close_fds,
6 File "D:\software\python\lib\subprocess.py", line 1307, in _execute_child
7 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
8 FileNotFoundError: [WinError 2] 系统找不到指定的文件。
错误的原因提示系统找不到指定的文件,导致错误的原因,找不到chromedriver
解决方法:
1。修改代码,把chromedrive安装路径填入,如下:
driver = webdriver.Chrome("C:/Program Files/Google/Chrome/Application/chromedriver.exe")
2。把chromedriver.exe的文件放在python安装路径中,如:D:\software\python\chromedriver.exe
3。修改电脑中Python安装目录中的lib下的subprocess.py文件中__init__中的shell=False。(感觉没什么用)