路径不对 导致FileNotFoundError: [WinError 2] 系统找不到指定的文件, 问题解决办法
执行python + selenium 代码
from selenium import webdriver
driver = webdriver.Chrome("D:\AutoConf\bin\chromedriver.exe")
driver.get("http://www.baidu.com")
报错:FileNotFoundError: [WinError 2] 系统找不到指定的文件。
D:\pycode\test\venv\Scripts\python.exe D:/pycode/test/Testa/test01.py
Traceback (most recent call last):
File "D:\pycode\test\venv\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Python36-32\Lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Python36-32\Lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/pycode/test/Testa/test01.py", line 3, in <module>
driver = webdriver.Chrome("D:\AutoConf\bin\chromedriver.exe")
File "D:\pycode\test\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
self.service.start()
File "D:\pycode\test\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1
原因是指定chromedriver路径错误中用了 window路径正斜杠,正确的是用反斜杠
正确的代码
from selenium import webdriver
#driver = webdriver.Chrome("D:\AutoConf\bin\chromedriver.exe") #错误的路径 使用正斜杠
driver = webdriver.Chrome("D:/AutoConf/bin/chromedriver.exe") #正确的路径 使用反斜杠
driver.get("http://www.baidu.com")
路径不对 导致FileNotFoundError: [WinError 2] 系统找不到指定的文件, 问题解决办法的更多相关文章
- python FileNotFoundError: [WinError 2] 系统找不到指定的文件。
D:\Test\TestSWP\Scripts\python.exe D:/Test/SWP/TestSWP/chorme/chorme.pyTraceback (most recent call l ...
- 在使用selenium时出现FileNotFoundError: [WinError 2] 系统找不到指定的文件。
今天在使用selenium出现这样的错: Traceback (most recent call last): File "E:\python\lib\site-packages\selen ...
- FileNotFoundError: [WinError 2] 系统找不到指定的文件
用Idle运行Python脚本的时候发现如下错误: Traceback (most recent call last): File "D:\Python\Python36-32\lib\s ...
- FileNotFoundError: [WinError 2] 系统找不到指定的文件。 解决方案
用Idle运行Python脚本的时候发现如下错误: Traceback (most recent call last): File "C:\Users\DangKai\Desktop\pyt ...
- pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path && FileNotFoundError: [WinError 2] 系统找不到指定的文件。
C:\Users\k\Desktop\test>python test.py Traceback (most recent call last): File , in run_tesseract ...
- 转换文件格式遭遇 FileNotFoundError:[WinError 2]系统找不到指定的文件
重启试试
- TextClip构造方法报OSError:MoviePy creation of None failed because of the following [WinError 2]系统找不到指定的文件
☞ ░ 前往老猿Python博文目录 ░ 在使用moviepy的构造方法创建实例时报错: "C:\Program Files\Python37\python.exe" F:/stu ...
- [Python学习]错误篇二:切换当前工作目录时出错——FileNotFoundError: [WinError 3] 系统找不到指定的路径
REFERENCE:<Head First Python> ID:我的第二篇[Python学习] BIRTHDAY:2019.7.13 EXPERIENCE_SHARING:解决切换当前工 ...
- building '_mysql' extension error: [WinError 2] 系统找不到指定的文件。
D:\4yanjiiu\APIzidong\MySQL-python-1.2.5>py running install running bdist_egg running egg_info wr ...
随机推荐
- Storm本地模式异常
来自:http://isuifengfei.iteye.com/blog/1998265 问题1 java.net.SocketException: Address family not supp ...
- VB6 获取和设置默认打印机
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA&quo ...
- MongoDB numa系列问题二:WARNING: You are running on a NUMA machine.
1:Mongod日志warning: mongodb日志显示如下: WARNING: You are running on a NUMA machine. We suggest launching m ...
- Oracle内存结构:SGA PGA UGA
内存结构是oracle数据库最重要的组成部分之一,在数据库中的操作或多或少都会依赖到内存,是影响数据库性能的重要因素Oracle数据库中包括3个基本的内存结构: 一. 系统全局区 (System G ...
- Selenium上传文件
selenium自带了对应的API可以上传问题,如果这个上传文件的html code中显示的type是file那么你就可以使用下面的代码上传文件. /** * click the upload but ...
- vs code 问题:preLaunchTask“build”已终止,退出代码为 1。解决办法
菜单:任务-配置任务 改为如下: { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation ab ...
- NE555
Turn-off time less than 2μsMax. operating frequency greater than 500kHzTemperature stability of 0.00 ...
- Makefile 和 CMakeLists.txt
Makefile Makefile 的格式 target: prerequisites [tab]command 例子 #Makefile all:chap1 chap2 chap1: - - - : ...
- Centos下和Win7下查看端口占用情况
Centos #会列出所有正在使用的端口及关联的进程/应用 netstat -nap #portnumber要用具体的端口号代替,可以直接列出该端口听使用进程/应用 lsof -i :portnumb ...
- 【bootstrapV3】移动端和PC端的 滚动监听
1.本代码适用于 bootstrap V3 的 页面滚动监听 2.效果: 3.代码: <!DOCTYPE html> <html lang="zh-CN"> ...