这篇文章讲的是mac下的chromedriver和selenium安装。
各位同学在上手学习pyecharts时会有将网页上的图片渲染到本地的需求,如以下官方代码:
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot
bar = (
Bar()
.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
)
make_snapshot(snapshot, bar.render(), "bar.png")
直接执行会报以下错误:
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
提示需要安装selenium和chromedriver,安装selenium很简单,直接pip install即可。
然后安装chromedriver会有一些问题,比如说用homebrew安装会出现以下提示: