解决: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

  • 19
    点赞
  • 44
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tp_0moyi0

新手入行,慢慢学习,慢慢积累

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值