【问题标题】:Selenium WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATHSelenium WebDriverException:消息:“chromedriver.exe”可执行文件需要在 PATH 中
【发布时间】:2017-08-10 04:59:51
【问题描述】:

我意识到这是重复的,但我已经尝试了其他类似帖子对此错误提出的所有建议。我正在运行 Windows 10。

根据这篇文章,他们建议在我的 python 代码中明确说明文件夹位置。我已经做到了。 Error message: "'chromedriver' executable needs to be available in the path"

在另一篇文章中,他们说要确保正确指向环境变量 PATH。 Error message: "'chromedriver' executable needs to be available in the path"

以下是我尝试输入代码的不同方式:

driver = webdriver.Chrome(executable_path='/Users/Admin/Documents/Python/chromedriver.exe'‌)  #SyntaxError: invalid character in identifier

driver = webdriver.Chrome('/Users/Admin/Documents/Python/chromedriver.exe')

截图如下:

另一个:

还将 chromesetup.exe 添加到 C:\Python36-32\Scripts 文件夹并调用

driver= webdriver.Chrome()

我还重新启动了我的计算机并重新启动了 Pycharm。还有其他建议吗?

【问题讨论】:

  • 我能够使用 Microsoft Edge 运行脚本。没问题。 driver = webdriver.Edge() 我的 C:/Python36-32 文件夹中的 Edge 驱动程序和 PATH 已更新。

标签: python windows path selenium-chromedriver


【解决方案1】:

driver = webdriver.Chrome(executable_path=os.path.abspath("ChromeSetup"), options=chrome_options)

【讨论】:

  • 使用脚本的代码在脚本所在的当前文件夹中找到chromedriver应用程序
猜你喜欢
  • 1970-01-01
  • 2017-03-04
  • 1970-01-01
  • 2020-06-05
  • 1970-01-01
  • 2020-04-25
  • 2018-11-26
  • 2021-06-16
  • 2018-10-10
相关资源
最近更新 更多