编程语言
首页 > 编程语言> > python selenium3.0 解决:提示FileNotFoundError: [WinError 2] 系统找不到指定的文件问题

python selenium3.0 解决:提示FileNotFoundError: [WinError 2] 系统找不到指定的文件问题

作者:互联网

用python使用selenium 模拟firefox来抓取网页时, 会出现提示FileNotFoundError: [WinError 2] 系统找不到指定的文件的问题,

 

代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")

运行后会出现提示

============= RESTART: D:\python\test.py =============
Traceback (most recent call last):
  File "C:\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 62, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Python\Python36\lib\subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "C:\Python\Python36\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

 

解决方法:

打开python目录下的lib文件夹,找到subprocess.py

1、搜索class Popen(object):

2、将__init__中的shell=False修改为shell=True

重新运行就能正常执行了。

标签:WinError,__,selenium3.0,lib,webdriver,python,py,selenium
来源: https://blog.csdn.net/lynxzong/article/details/90597537