How can I insert path (environmental variable) for geckodriver in goggle colab?

家住魔仙堡 提交于 2019-12-03 21:54:37

问题


I want to run selenium in Google Colab through gecko driver, but it told me: executable needs to be in PATH

I uploaded firefox and gecko driver in Google Colab and copied gecko driver's path. The code worked well on my PC.

firefox and gecko driver in google clob, but an error occurred.

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.

I want gecko driver should be known by selenium in Google Colab environment.


回答1:


I made a gist on how to use chrome+selenium on Colab here.

https://gist.github.com/korakot/5c8e21a5af63966d80a676af0ce15067

The key is to copy the driver to PATH (here is /usr/bin)

!cp /usr/lib/chromium-browser/chromedriver /usr/bin

You can try copy your gecko driver there as well. But you cannot use the exe file which only run on Windows.



来源:https://stackoverflow.com/questions/54327654/how-can-i-insert-path-environmental-variable-for-geckodriver-in-goggle-colab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!