python - 无法为 Selenium 使用 chrome 驱动程序

标签 python google-chrome python-3.x selenium python-3.3

我在使用 Selenium 的 Chrome 驱动程序时遇到问题。我已将 chromedriver 下载并保存到 C:\Chrome:

driver = webdriver.Chrome(executable_path="C:/Chrome/")

使用它会给我以下错误:

Traceback (most recent call last):
  File "C:\Python33\lib\subprocess.py", line 1105, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\service.py", line 63, in start
    self.service_args, env=env, stdout=PIPE, stderr=PIPE)
  File "C:\Python33\lib\subprocess.py", line 817, in __init__
    restore_signals, start_new_session)
  File "C:\Python33\lib\subprocess.py", line 1111, in _execute_child
    raise WindowsError(*e.args)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Wilson/Dropbox/xxx.py", line 71, in <module>
    driver = webdriver.Chrome(executable_path="C:/Chrome/")
  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 59, in __init__
    self.service.start()
  File "C:\Python33\lib\site-packages\selenium\webdriver\chrome\service.py", line 68, in start
    and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.                 Please download from http://chromedriver.storage.googleapis.com/index.html  

任何帮助将不胜感激。

最佳答案

您应该指定可执行文件路径,而不是包含可执行文件的目录路径。

driver = webdriver.Chrome(executable_path=r"C:\Chrome\chromedriver.exe")

关于python - 无法为 Selenium 使用 chrome 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22130109/

相关文章:

python - 用另一个二维数组索引 NumPy 二维数组

python - 如何在Python中将文本文件转换为JSON?

google-chrome - SSL Localhost 隐私错误

Python 没有名为 X 的模块 - 绝对导入

python - 有没有用 wxPython 开发过流行的桌面应用程序?

javascript - 在哪里存储 Chrome 扩展程序的 HTML 片段

python - Selenium Python 在 VPS 中设置 Chrome 默认下载目录

python-3.x - 目前可用于在 python3 上使用 flask 的 websockets 的最佳选择

python-3.x - 用于图中第二个图的 Bokeh Hovertool

python - `self` 对于 Python 中的类方法实际上是强制性的吗?