python - Selenium 错误:“chromedriver”可执行文件需要在 PATH 中
问题描述
我在运行 Debian 9 的计算机上安装了 Chromium。这里是scraper.py
:
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument("--ignore-certificate-errors")
options.add_argument("--test-type")
options.binary_location = "/usr/bin/chromium"
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://python.org")
Chromium 二进制文件位于指定位置。当我运行 pythonscraper.py
时,我收到此错误。
Traceback (most recent call last):
File "scraper.py", line 9, in <module>
driver = webdriver.Chrome(chrome_options=options)
File "/home/me/ENV/pbc_vss/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/home/me/ENV/pbc_vss/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
解决方案
指定你的chrome驱动所在的路径,下载页面https://sites.google.com/a/chromium.org/chromedriver/downloads
driver = webdriver.Chrome(executable_path='/path/to/driver/chromedriver')
推荐阅读
- tensorflow - 如何使用 TensorFlow 的 Keras API 为每个 epoch 的保存模型生成唯一名称
- java - 如何使@autowired 在通用 portlet 中工作(扩展 GenericPortlet)以及如何在没有 Web 上下文的情况下使 spring 工作(创建 bean)
- r - 无法在 R 中拟合马尔可夫模型
- r - 如何使用summary 和group_by?
- powershell - Export-csv 返回 1 个实例而不是整个结果
- javascript - 删除“编辑”文本单击“删除”文本
- amazon-web-services - AWS CLI:如何设置新复制实例的 VPC
- sql-server - 以整数值作为日期参数的 T-SQL 日期函数
- protocol-buffers - 多个原型中的 FileOptions 扩展
- ajax - 如何在 laravel 中使用 ajax 使用搜索栏?