3

I am trying to use Selenium in Google Colab, but i get some errors when i try to run a Firefox instance. i followed this links:

  • Selenium documentation here, i tried with the Driver Management Software but i got the error that says that was unable to find the binary location to Firefox, so i follow this other link , but i was unable to make it run

So i tried with the Hard Coded Location, but I got the error:

Message: 'geckodriver' executable needs to be in PATH.

I actually downloaded the geckodrive and follow this link

I've uploaded the grecodriver to my Drive and access with the google.colab library, but i always got the error:

No such file or directory: '/content/drive/MyDrive/Santillana/geckodriver'

Here is my code:

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager
from google.colab import drive

drive.mount('/content/drive', force_remount=True)

service = FirefoxService(executable_path= '/content/drive/MyDrive/Santillana/geckodriver')
driver = webdriver.Firefox(service=service)

My drive´s files

The entire error:

---------------------------------------------------------------------------

FileNotFoundError                         Traceback (most recent call last)

/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in start(self)
     75                                             stdin=PIPE,
---> 76                                             creationflags=self.creationflags)
     77         except TypeError:

4 frames

FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Santillana/geckodriver': '/content/drive/MyDrive/Santillana/geckodriver'


During handling of the above exception, another exception occurred:

WebDriverException                        Traceback (most recent call last)

/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in start(self)
     81                 raise WebDriverException(
     82                     "'%s' executable needs to be in PATH. %s" % (
---> 83                         os.path.basename(self.path), self.start_error_message)
     84                 )
     85             elif err.errno == errno.EACCES:

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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Ernesto
  • 129
  • 2
  • 10
  • `geckodriver.exe` is a file and not a folder, right? Try replacing the `geckodriver` in `service = FirefoxService(executable_path= '/content/drive/MyDrive/Santillana/geckodriver')` to `geckodriver.exe` to make the line: `service = FirefoxService(executable_path= '/content/drive/MyDrive/Santillana/geckodriver.exe')`. Maybe that's the problem – The Amateur Coder Jan 24 '22 at 15:49
  • 1
    @TheAmateurCoder it is a file, and it is not necessary put '.exe', even so i tried and give error that says that geckodriver dont have permission. – Ernesto Jan 24 '22 at 17:31

1 Answers1

1

This error message...

FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Santillana/geckodriver': '/content/drive/MyDrive/Santillana/geckodriver'

...implies that your program was unable to locate the GeckoDriver executable.


Analysis

As per the error message it seems you are on a system. However you have downloaded the version of GeckoDriver:

downloaded


Solution

Instead of the Windows version of GeckoDriver possibly you need to download the Linux version of GeckoDriver executable.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    i tried with the linux version but i get the error: ``` Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line ``` the same that i got when i try with the Driver Management Software driver installation, so i suppose that i must have some firefox installation in my colab?, but i don't think is correct – Ernesto Jan 24 '22 at 17:25
  • 2
    That's even a better error, atleast we are using the correct version of GeckoDriver. Shouldn't _`Expected browser binary location, but unable to find binary in default location`_ be a different question all together? – undetected Selenium Jan 24 '22 at 17:27