selenium.common.exceptions.WebDriverException错误解决

selenium.common.exceptions.WebDriverException错误解决

参考资料

https://blog.csdn.net/mango_ZZY/article/details/105138176
https://selenium-python.readthedocs.io/installation.html#drivers

说明

今天在python3.7环境下用snapshot_selenium渲染pyecharts的图片,报了以下错:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.

应该是浏览器驱动的问题,在网上查了一些资料,直接上解决方法。

解决

以Google为例。
第一步:Google浏览器输入chrome://version/查看版本。


Google Chrome	76.0.3809.132 (正式版本) (64 位)

第二步:去下面的网址下载相应版本的chromedriver。大版本对应即可。

http://chromedriver.storage.googleapis.com/index.html
http://npm.taobao.org/mirrors/chromedriver/
在这里插入图片描述
第三步:将解压后的chromedriver.exe放到python根目录下面。由于我使用的是anaconda的python虚拟环境,所以放在了使用到的python版本环境下面。
在这里插入图片描述
大功告成,程序可以正常运行了!
这个方法对比网上的一些方法,省去了很多步骤,但是已经达到了效果。

讨论

在一开始查资料的时候,是找的pyecharts文档。

snapshot-selenium 是 pyecharts + selenium 渲染图片的扩展,
使用 selenium 需要配置 browser driver,
这部分可以参考 selenium-python 相关介绍,
推荐使用 Chrome 浏览器,
可以开启 headless 模式。
目前支持 Chrome, Safari。

根据文档提示,去参考了selenium-python相关介绍。
其中的描述是这样的:
Selenium requires a driver to interface with the chosen browser. Firefox, for example, requires geckodriver, which needs to be installed before the below examples can be run. Make sure it’s in your PATH, e. g., place it in /usr/bin or /usr/local/bin.
其中提到驱动需要在我的环境变量里面,网上的一些解决方案也是利用环境变量。
但是,我在环境变量里边配置了chromedriver,重启后,问题并没有解决。
后来以为跟我的虚拟环境有关系,在默认环境下利用环境变量解决问题,还是不行。
不知道问题出在哪里,有点懵逼。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值