【问题标题】:Selenium - Expected browser binary location, but unable to find binary in default locationSelenium - 预期的浏览器二进制位置,但无法在默认位置找到二进制文件
【发布时间】:2021-07-18 07:18:22
【问题描述】:

我对 Python 和所有相关的东西都是全新的。我正在使用这个叫做 Instapy 的东西,这是我在运行 windows.start 文件时遇到的错误。

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

感谢您的帮助,保持安全并度过美好的一天!

【问题讨论】:

    标签: python selenium selenium-webdriver


    【解决方案1】:

    您可以通过两种不同的方式避免此问题:

    1. 明确在哪里可以找到您的 selenium 代码的 firefox 二进制文件:
    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. firefox 添加到您的PATH 环境变量中。 (Windows、Ubuntu)

    【讨论】:

    • 嘿,我无法编辑显示的文本,只要我按下任何按钮 - 它就会退出应用程序。有什么建议吗?那是显示的错误,我根本无法更改任何内容。谢谢麦迪!!顺便说一句,我非常感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 2018-03-31
    • 2021-09-22
    • 2021-03-02
    • 2021-05-06
    • 1970-01-01
    • 2020-11-04
    • 2021-03-26
    • 2022-06-29
    相关资源
    最近更新 更多