My Solution
from instapy import InstaPy
session = InstaPy(username="username", password="password", browser_executable_path=r"C:\Program Files\Mozilla Firefox\firefox.exe")
session.login()
Pass browser_executable_path = r"C:[Custom Location]" in your Session instance.
Reinstalling Firefox did not work for me.
Explanation
selenium.common.exceptions.SessionNotCreatedException: 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
That message implies that the GeckoDriver was unable to locate the Firefox binary (firefox.exe) while trying to initiate/spawn a new browsing context i.e. Firefox browser-session.
Why?
Probably for 1 of 2 reasons:
- Firefox isn't installed in your system.
- Firefox isn't installed in the default location within your system.
Normally, any Selenium project would take...
options = webdriver.firefox.options.Options()
options.binary_location = r"C:\Program Files\Mozilla Firefox\firefox.exe"
browser = webdriver.Firefox(options=options)
...for a customized location passing the absolute path of the firefox binary through an Options() instance, but since InstaPy handles initializing the browser, you must pass this through the class attribute "browser_executable_path".
TL;DR: Adding the parameter browser_executable_path of the InstaPy class allowed me to pass the r"C:[Custom Firefox Location]" as the firefox location.
References