gunicorn[15246]:消息:"壁虎驱动程序"可执行文件需要在 PATH 中



我目前正试图在Ubuntu 20.04服务器上使用selenium和geckodriver运行python脚本。我正在使用gunicorn和nginx来设置我的flask应用程序,但几天来我一直在尝试在所有类似的文章中使用每个答案,但仍然没有什么对我和其他人一样有效。

有人知道我做错了什么吗?

Firefox版本–Mozilla Firefox 81.0

硒版本-3.141.0

壁虎驱动程序版本–0.27.0

代码:(我已经尝试了下面的6个(

def login(self):
try:
print("Logging in...")
# 1)
ff_options = FirefoxOptions()
ff_options.headless = True
self.driver = webdriver.Firefox(options=ff_options)
# 2)
ff_options = FirefoxOptions()
ff_options.headless = True
self.driver = webdriver.Firefox(executable_path="./geckodriver", options=ff_options)
# 3)
self.driver = webdriver.Firefox()
# 4)
self.driver = webdriver.Firefox('./geckodriver')
# 5)
binary = FirefoxBinary('/usr/local/bin/geckodriver')
browser = webdriver.Firefox(firefox_binary=binary)
# 6)
binary = FirefoxBinary('/usr/bin/firefox')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="/home/ubuntu/cole/instagram_bot_v2")
self.driver.get('https://www.instagram.com/accounts/login')

我收到的错误:

Oct 12 07:00:11 ip-172-31-32-84 gunicorn[15245]: Message: 'geckodriver' executable needs to be in PATH.

我尝试将geckodriver可执行文件本身放在/usr/bin、/usr/local/bin以及我的项目目录中,所有文件都设置为可执行文件,但运行时似乎没有什么区别,它们都会得到相同的路径错误。

有人知道我可以尝试什么吗?

您可以做的一件事是将geckodriver移动到保存程序的同一目录中。然后,您可以通过使用webdriver.Firefox()而不是指定可执行文件的完整路径来启动geckodriver。这会为你节省很多时间。

相关内容

最新更新