首页 > 解决方案 > 无法连接到python3中的服务/usr/local/bin/geckodriver

问题描述

我的代码:

#!/usr/bin/python3

from selenium import webdriver

driver=webdriver.Firefox(executable_path=r'/usr/local/bin/geckodriver')
driver.get('http://www.python.org')

产生以下错误:

错误:消息:无法连接到服务 /usr/local/bin/geckodriver

我的设置:

我怎样才能解决这个问题?

标签: pythonpython-3.xseleniumselenium-webdrivergeckodriver

解决方案


将 geckodriver 文件移动到 /usr/bin ,然后更改代码如下。

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)

希望它有帮助。它在我身边有效。


推荐阅读