1

There's no problem on my local machine. But when I deployed it in cloud server specifically in Scrapinghub I need to add geckodriver

How can include geckodriver in my requirement.txt?

here's my working code

 from selenium import webdriver
 from selenium.webdriver.support.ui import WebDriverWait
 from selenium.webdriver.common.by import By
 from selenium.webdriver.support import expected_conditions as EC
 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
 from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

 def parse_subpage(self, response):

        profile = webdriver.FirefoxProfile()
        profile.set_preference("network.proxy.type", 1)
        profile.set_preference("network.proxy.http", 
                    "localhost")
        profile.set_preference("network.proxy.http_port", 
                    3128)
        profile.update_preferences()

        capabilities = webdriver.DesiredCapabilities().FIREFOX
        capabilities["marionette"] = True
        driver = webdriver.Firefox(capabilities=capabilities, 
                    firefox_profile=profile)

        driver.get('sample.com')
        driver.quit() 

my Requirement.txt

mysql-connector-python
pytz==2018.9
selenium==3.13.0
geckodriver==0.24.0 

Error observed:

ERROR: Could not find a version that satisfies the requirement geckodriver==0.24.0 (from -r /app/requirements.txt (line 4)) (from versions: none)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

1

This error message...

Could not find a version that satisfies the requirement geckodriver==0.24.0 (from -r /app/requirements.txt (line 4)) (from versions: none)

...implies that the there was an error while GeckoDriver tried to initiate a browsing session through Firefox.

Seems there is no incompatibility between geckodriver==0.24.0 and selenium==3.13.0 as per the documentation in Supported platforms.

Presumably, it looks like an issue with the installation location of Mozilla Firefox. Either Firefox is not installed within your system or Firefox is not installed at the default (desired) location.


Solution

You need to have Firefox installed at the default location. Incase Firefox is installed at a customized location you need to pass the absolute path of the firefox binary as follows:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

capabilities = webdriver.DesiredCapabilities().FIREFOX
capabilities["marionette"] = True
binary = FirefoxBinary('C:/Program Files/Mozilla Firefox/firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, capabilities=capabilities, executable_path="C:/Utility/BrowserDrivers/geckodriver.exe")
driver.get("http://www.google.com")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Hi @debanjanB, I cannot use local path since I am deploying it through cloud server specifically in scrapinghub. I have no problem when using the script on my local machine. – Christian Read Jun 12 '19 at 15:52
  • @ChristianRead Well, I saw this question coming just like Google CoLab scenarios. My point is, to work with Selenium and GeckoDriver you need to have Mozilla Firefox installed for sure. – undetected Selenium Jun 12 '19 at 15:55
  • Yes will take note of that thank you for helping me. Will try other approach to fix this problem – Christian Read Jun 12 '19 at 16:02
  • @ChristianRead For your reference here is the [Google Colab issue](https://stackoverflow.com/questions/53532060/webdriverexception-message-service-content-chromedriver-unexpectedly-exited/53537003#53537003) where we discussed similar issue with _ChromeDriver_ / _Chrome_ installation. – undetected Selenium Jun 12 '19 at 16:07