解决:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ execu

这篇具有很好参考价值的文章主要介绍了解决:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ execu。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

运行爬虫代码出现上面的bug

bug详细信息如下

D:\Anaconda3\file\envs\item\python.exe D:/pycharm/code/BadmintonCrawler.py
D:\pycharm\code\BadmintonCrawler.py:22: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(executable_path=r"1D:\Anaconda3\file\envs\item\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe", options=options)
Traceback (most recent call last):
  File "D:\Anaconda3\file\envs\item\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "D:\Anaconda3\file\envs\item\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\Anaconda3\file\envs\item\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\pycharm\code\BadmintonCrawler.py", line 102, in <module>
    bc = BadmintonCrawler()
  File "D:\pycharm\code\BadmintonCrawler.py", line 17, in __init__
    self.__login()
  File "D:\pycharm\code\BadmintonCrawler.py", line 22, in __login
    driver = webdriver.Chrome(executable_path=r"1D:\Anaconda3\file\envs\item\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe", options=options)
  File "D:\Anaconda3\file\envs\item\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "D:\Anaconda3\file\envs\item\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, in __init__
    self.service.start()
  File "D:\Anaconda3\file\envs\item\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

 解决方法

如下

1.先打开chrome 输入 “chrome://version/”来查看chrome版本 如图我的是96

 

2.然后访问此网站  http://chromedriver.storage.googleapis.com/index.html   然后选择合适版本的driver 

 我这边是windows版本的系统所以下载  win32版本的压缩包

 解压后里面是个这个东西

3.  把解压后的   chromedriver.exe  文件放入  python  所在的环境中

4.  之后再把代码中的路径 修改成上面文件放入的路径 

driver = webdriver.Chrome(executable_path=r"D:\Anaconda3\file\envs\item\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe", options=options)

 然后运行就可以了

 之前的bug就解决了,上面的这个是另外的其他的bug文章来源地址https://www.toymoban.com/news/detail-596185.html

到了这里,关于解决:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ execu的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包