问题描述:
Selenium中执行browser = webdriver.Firefox()执行时报错,执行及报错信息如下:
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> from selenium import webdriver
>>> browser = webdriver.Firefox()
Traceback (most recent call last):
File "C:\Users\femtel\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\femtel\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\femtel\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] 系统找不到指定的文件。
解决方法:
步骤1:在python的安装目录下Lib目录下找到subprocess.py文件。
步骤2:修改如下shell=True,保存即可。
推 荐 阅 读
如何退出python当前运行环境?安装Selenium包'pip' 不是内部或外部命令,也不是可运行的程序 或批处理文件?