Selenium 如何在google colab中插入geckodriver的路径(环境变量)?

Selenium 如何在google colab中插入geckodriver的路径(环境变量)?,selenium,firefox,path,google-colaboratory,geckodriver,Selenium,Firefox,Path,Google Colaboratory,Geckodriver,我想通过gecko驱动程序在Google Colab中运行selenium,但它告诉我:可执行文件需要在路径中 我将firefox和gecko驱动程序上传到GoogleColab中,并复制了gecko驱动程序的路径。代码在我的电脑上运行良好 google clob中的firefox和gecko驱动程序,但出现错误 from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait as wa

我想通过gecko驱动程序在Google Colab中运行selenium,但它告诉我:可执行文件需要在路径中

我将firefox和gecko驱动程序上传到GoogleColab中,并复制了gecko驱动程序的路径。代码在我的电脑上运行良好

google clob中的firefox和gecko驱动程序,但出现错误

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support import ui
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from selenium.common.exceptions import TimeoutException


driver =  webdriver.Firefox(executable_path=r'content/geckodriver.exe')

WebDriverException: Message: 'content/geckodriver.exe' executable needs to be in PATH.

我希望gecko驱动程序应该被Google Colab环境中的selenium知道。

我在这里就如何在Colab上使用chrome+selenium做了一个要点

关键是将驱动程序复制到PATH(这里是/usr/bin)

!cp/usr/lib/chromium浏览器/chromedriver/usr/bin


你也可以试着在那里复制你的gecko驱动程序。但是您不能使用仅在Windows上运行的
exe
文件。

是否检查了selenium版本和Firefox版本之间的同步条件?它们兼容吗?是的。这是正确的。我在我的电脑上试用了你的代码,效果很好。你有什么问题?我知道。正如我在问题中已经说过的,它在我的电脑上正常工作,但我无法在GoogleColab上运行。请检查此URL:虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,则仅链接的答案可能无效。FileNotFoundError:[Errno 2]没有此类文件或目录:“chromedriver”:“chromedriver”