python webdriver eror
<p>I have recently downloaded selenium and tried to run this script: </p>

<pre><code> from selenium import webdriver
 driver = webdriver.Firefox()
</code></pre>

<p>but I get this error:</p>

<pre><code>Traceback (most recent call last):
  File "&lt;pyshell#3&gt;", line 1, in &lt;module&gt;
    driver = webdriver.Firefox()
  File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 145, in __init__
    keep_alive=True)
  File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: Expected browser binary location, but unable to find binary in default location, no 'firefox_binary' capability provided, and no binary flag set on the command line
</code></pre>

<p>Oh by the way this open me geckodriver.exe before its write the eror</p>

<p>I got around this by manually setting the binary location as per the following answer:</p>

<p><a href="http://stackoverflow.com/a/25715497">http://stackoverflow.com/a/25715497</a></p>

<p>Remember to set your binary to the actual location of the firefox binary on your computer</p>

<p>eg:</p>

<pre><code>from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
self.browser = webdriver.Firefox(firefox_binary=binary)
</code></pre>

<p>(note: the 'r' before the first quote in the file path string makes python see the string as 'raw' text, and therefore you don't need to escape characters like '\' - you can just put in the path as it actually is)</p>

python selenium path webdriver