'aws lambda: How to fix 'geckodriver' executable needs to be in PATH"

So I am trying to use firefox in aws lambda runtime Python3.6 I have added my dependencies using layers in this order: selenium3.14, geckodriver25 and firefox 69 binary, to create my webdriver instance I am using this code:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
path = '/tmp/'

def start_browser(url, headless=True):
    fp = webdriver.FirefoxProfile()
    options = Options()
    if headless==True:
        options.headless = True
    fp.set_preference("browser.preferences.instantApply",True)
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/xls, application/vnd.ms-excel")
    fp.set_preference("browser.helperApps.alwaysAsk.force",False)
    fp.set_preference("browser.download.dir", path)
    fp.set_preference("browser.download.folderList", 2)
    fp.set_preference("browser.download.manager.showWhenStarting", False)
    browser = webdriver.Firefox(
        options=options,
        executable_path="/opt/geckodriver",
        log_path="/tmp/geckodriver.log",
        firefox_profile=fp,
        firefox_binary="/opt/firefox/firefox"

    )
    browser.get(url)
    return browser

My function executes but I get this response when testing from aws console

{
  "message": "Your function executed unsuccessfully!",
  "event": "Message: 'geckodriver' executable needs to be in PATH. \n"
}


Solution 1:[1]

I needed to change my path to lambda dependecies from "/opt/my_dependency" to "/opt/python/my_dependency"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 imlearningcode