0

I am trying to use some bots on my Instagram page, but I can’t log in.

This is my code:

from instapy import InstaPy
session = InstaPy(username='' ,password='') 
session.login()

I’m getting this error:

SessionNotCreatedException: 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

I have the latest version of Firefox.

Thank you!

Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150
lemar1217
  • 13
  • 1
  • 3
  • Read stackoverflow guideline for posting code segment. It should be like this ```from instapy import InstaPy session = InstaPy(username='' ,password='') session.login()``` – Lawhatre Nov 18 '20 at 05:41

2 Answers2

2

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:

  1. Firefox isn't installed in your system.
  2. 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

-2

Your code should look like this:

from instapy import InstaPy

session = InstaPy(username='', password='')
session.login()

Make sure you are placing your login information for the Instagram account you are using into the username and password parameters as well.

CremBluRay
  • 12
  • 1
  • Thank you for your response, i still getting the same error. SessionNotCreatedException: 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 – lemar1217 Nov 18 '20 at 15:43
  • it is all fix PUT FIREFOX on the path in edit variables – lemar1217 Nov 18 '20 at 17:03