【问题标题】:When I try to use Selenium with python to open a Chrome browser, windows gives me a FileNotFoundError: [WinError 2]当我尝试使用 Selenium 和 python 打开 Chrome 浏览器时,windows 给了我一个 FileNotFoundError: [WinError 2]
【发布时间】:2016-01-29 22:34:34
【问题描述】:

这是我的代码:

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com/")

然后在 Windows PowerShell 中我得到:

PS C:\Users\userName\PycharmProjects\untitled> python .\s_Chrome.py
Traceback (most recent call last):
File "C:\Users\userName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium-2.49.2-py3.5.egg\selenium\webdriver\common\service.py", line 62,
in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\userName\AppData\Local\Programs\Python\Python35-32\lib\subproce
ss.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\userName\AppData\Local\Programs\Python\Python35-32\lib\subproce
ss.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

我需要在 PATH 中添加一些东西吗?

【问题讨论】:

标签: python google-chrome selenium


【解决方案1】:

您的PATH 中需要有chromedriver 可执行文件。前往here获取更多信息并下载适用于各种平台的chromedriver。

【讨论】:

  • 谢谢@MattDMo!周末我在我的个人 linux 机器上意识到了这一点。如果我更频繁地检查我的 stackoverflow 问题,本可以节省自己的时间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-26
  • 1970-01-01
相关资源
最近更新 更多