在 Python 中使用Selenium 包进行数据分析时,遇到一个错误:
WebDriverException: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
解决方法如下:安装 selenium 的 python 包之后,还要安装chromedriver(浏览器 driver),我使用的是chrome,chrome浏览器驱动下载链接:https://sites.google.com/a/chromium.org/chromedriver/。然后复制chromedriver.exe文件到 Google Chrome 程序目录下,例如:C:\Program Files (x86)\Google\Chrome\Application。在Python 代码里创建 webdriver 对象时传递chromedriver.exe的路径,并且包含chromedriver文件名,例:
chromedriver = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver'
driver = webdriver.Chrome(chromedriver)
本文详细介绍了在Python中使用Selenium进行数据分析时,如何解决因ChromeDriver未正确配置而导致的WebDriverException错误。通过下载ChromeDriver并将其放置于Chrome程序目录下,再在Python代码中指定ChromeDriver的路径,即可成功运行Selenium。
1274

被折叠的 条评论
为什么被折叠?



