执行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] 系统找不到指定的文件, 问题解决办法的更多相关文章

  1. python FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    D:\Test\TestSWP\Scripts\python.exe D:/Test/SWP/TestSWP/chorme/chorme.pyTraceback (most recent call l ...

  2. 在使用selenium时出现FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    今天在使用selenium出现这样的错: Traceback (most recent call last): File "E:\python\lib\site-packages\selen ...

  3. FileNotFoundError: [WinError 2] 系统找不到指定的文件

    用Idle运行Python脚本的时候发现如下错误: Traceback (most recent call last):  File "D:\Python\Python36-32\lib\s ...

  4. FileNotFoundError: [WinError 2] 系统找不到指定的文件。 解决方案

    用Idle运行Python脚本的时候发现如下错误: Traceback (most recent call last): File "C:\Users\DangKai\Desktop\pyt ...

  5. 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 ...

  6. 转换文件格式遭遇 FileNotFoundError:[WinError 2]系统找不到指定的文件

    重启试试

  7. TextClip构造方法报OSError:MoviePy creation of None failed because of the following [WinError 2]系统找不到指定的文件

    ☞ ░ 前往老猿Python博文目录 ░ 在使用moviepy的构造方法创建实例时报错: "C:\Program Files\Python37\python.exe" F:/stu ...

  8. [Python学习]错误篇二:切换当前工作目录时出错——FileNotFoundError: [WinError 3] 系统找不到指定的路径

    REFERENCE:<Head First Python> ID:我的第二篇[Python学习] BIRTHDAY:2019.7.13 EXPERIENCE_SHARING:解决切换当前工 ...

  9. building '_mysql' extension error: [WinError 2] 系统找不到指定的文件。

    D:\4yanjiiu\APIzidong\MySQL-python-1.2.5>py running install running bdist_egg running egg_info wr ...

随机推荐

  1. POSTGRESQL表分区

    最近发现POSTGRESQL的一张表(下面统称为test表)达到67G大小,不得不进行重新分区,下面记录一下步骤: 前言.查看数据表结构(表结构肯定是虚构的) CREATE TABLE test ( ...

  2. JERSEY中文翻译(第一章、Getting Started、2.2)

    前言 这是jersey2.2的用户向导,我们会尽力维护它的更新并且也会增加新的章节.当阅读本用户指南的时候,也要参阅Jersey API 文档,额外的信息补充JERSEY的新特性和API 如果你想要为 ...

  3. NGINX高并发配置

    1.  worker_processes 8; nginx 进程数,建议按照cpu 数目来指定,一般为它的倍数 (如,2个四核的cpu计为8). 2.  worker_cpu_affinity 000 ...

  4. Java多线程之线程阻塞原语LockSupport的使用

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6558597.html  看名字就知道了,LockSupport——提供对加锁机制的支持. 它是提供线程阻塞的原 ...

  5. JavaWeb应用出现HTTP 500-Unable to compile class for JSP 错误 的解决

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6383192.html 在上一篇博文中,我们把自己本机的web项目部署到了云主机的tomcat上.之后通过浏览器 ...

  6. Plus One 加一运算

    Given a non-negative number represented as an array of digits, plus one to the number. The digits ar ...

  7. urllib2特点--urllib2.build_opener对象接口

    # -*- coding: cp936 -*- #python 27 #xiaodeng #urllib2特点--urllib2.build_opener对象接口 import urllib2 imp ...

  8. 解码url参数的lotusscript函数

    在Domino的系统开发过程中,我们往往要通过url来进行传参,传递参数给表单或者代理,假如浏览器请求的url带有参数,在交给服务器前服务器会对其进行编码(不知道这样理解对不对),像一些特殊符号,空格 ...

  9. 关于继承中的super()调用父类构造方法

    super super可以理解为是指向自己超(父)类对象的一个指针,而这个超类指的是离自己最近的一个父类. 每当你new一个子类对象的时候,子类对象都隐式内置了一个父类对象.所以说,为了那个内置的父类 ...

  10. RHEL7 添加网卡并设置多个IP地址

    首先在虚拟机管理界面中给该虚拟机添加一块虚拟网卡,VirtualBox虚拟机中要shutdown才能添加. [root@rhel7 ~]# nmcli device show | grep -i de ...