user15753445
user15753445

Reputation:

Selenium - Expected browser binary location, but unable to find binary in default location

I'm completely new to Python and everything related. I'm using this thing called Instapy and this is the error I get when I'm running the windows.start file.

Traceback (most recent call last):
  File "C:\Users\alexa\Downloads\instapy-quickstart-master\quickstart.py", line 14, in <module>
    session = InstaPy(username=insta_username,
  File "C:\Users\alexa\AppData\Local\Programs\Python\Python39\lib\site-packages\instapy\instapy.py", line 325, in __init__
    self.browser, err_msg = set_selenium_local_session(
  File "C:\Users\alexa\AppData\Local\Programs\Python\Python39\lib\site-packages\instapy\browser.py", line 123, in set_selenium_local_session
    browser = webdriver.Firefox(
  File "C:\Users\alexa\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 170, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\alexa\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\alexa\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\alexa\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\alexa\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
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

I appreciate your help, stay safe and have a great day!

Upvotes: 4

Views: 5730

Answers (1)

Viorelul
Viorelul

Reputation: 11

You can avoid this issue in two different ways:

  1. Explicit where to find firefox binary to your selenium code:
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium import webdriver
firefox_binary = FirefoxBinary('/usr/bin/firefox/')
driver = webdriver.Firefox(firefox_binary=firefox_binary)
  1. Add firefox to your PATH environment variable. (Windows, Ubuntu)

Upvotes: 1

Related Questions