title: Headless Selenium driver unable to find Firefox binary even when specified in code and $PATH on Shared Web Host
body: <h1>Goal</h1>
  
  <p>I am trying to get Selenium to run Firefox headless on my virtual python environment on my Dreamhost shared web host.</p>
  
  <h1>Problem</h1>
  
  <p>The selenium driver is unable to find my Firefox binary even though I have specified its path in my code and have added it to my PATH.</p>
  
  <h1>Information</h1>
  
  <p>I unpacked 64-bit firefox 46.0.1 tar to ~/bin/firefox. 
  I have also ran <code>chmod 777 ~/bin/firefox/firefox</code>.
  I do not have sudo access.</p>
  
  <pre><code>[SharedWebServer]$ cat ~/.bashrc
      export PATH="$PATH:~/bin/firefox"
      alias firefox="~/bin/firefox/firefox"
      alias pythonactivate='source $HOME/&lt;DOMAIN&gt;/env/bin/activate'
  [SharedWebServer]$ hash
      hits    command
      0       /home/&lt;user&gt;/bin/firefox/firefox
  [SharedWebServer]$ which firefox
  [SharedWebServer]$
  [SharedWebServer]$ export DISPLAY=:10
  [SharedWebServer]$ export
      declare -x DISPLAY=":10"
      declare -x GEM_HOME="/home/&lt;user&gt;/.gems"
      declare -x GEM_PATH="/home/&lt;user&gt;/.gems:/usr/lib/ruby/gems/1.8"
      declare -x HOME="/home/&lt;user&gt;"
      declare -x LC_COLLATE="C"
      declare -x LOGNAME="&lt;user&gt;"
      declare -x MAIL="/home/&lt;user&gt;/Maildir/"
      declare -x OLDPWD
      declare -x PATH="/home/&lt;user&gt;/.gems/bin:/usr/lib/ruby/gems/1.8/bin/:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
      declare -x PS1="[\\h]\$ "
      declare -x PWD="/home/&lt;user&gt;"
      declare -x SHELL="/bin/bash"
      declare -x SHLVL="1"
      declare -x SSH_CLIENT="&lt;blah&gt;"
      declare -x SSH_CONNECTION="&lt;blah&gt;"
      declare -x SSH_TTY="/dev/pts/1"
      declare -x TERM="xterm"
      declare -x USER="&lt;user&gt;"
  </code></pre>
  
  <h1>Code</h1>
  
  <pre><code>firefox_binary = FirefoxBinary(firefox_path='/home/&lt;user&gt;/bin/firefox/firefox')
  firefox_profile = custom_firefox_profile(images=False, css=True, flash=False)
  driver=webdriver.Firefox(firefox_binary=firefox_binary,firefox_profile=firefox_profile)
  vdisplay = Xvfb()
  vdisplay.start()
  </code></pre>
  
  <h1>Error</h1>
  
  <p>" Please specify the firefox binary location or install firefox")</p>
  
  <p>RuntimeError: Could not find firefox in your system PATH. Please specify the firefox binary location or install firefox</p>
  
  <h3>The actual error block:</h3>
  
  <pre><code>[SharedWebServer]$ source $HOME/&lt;DOMAIN&gt;/env/bin/activate
  (env)[SharedWebServer]$ python main.py
  
  Traceback (most recent call last):
  File "main.py", line 238, in &lt;module&gt;
    sys.exit(main())
  File "main.py", line 71, in main
    driver=webdriver.Firefox(firefox_binary=firefox_binary,firefox_profile=firefox_profile)
  File "/home/&lt;user&gt;/&lt;domain&gt;/env/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 67, in __init__
    firefox_options.binary_location = self.binary if isinstance(self.binary, basestring) else self.binary._get_firefox_start_cmd()
  File "/home/&lt;user&gt;/&lt;domain&gt;/env/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 163, in _get_firefox_start_cmd
  
  " Please specify the firefox binary location or install firefox")
  RuntimeError: Could not find firefox in your system PATH. Please specify the firefox binary location or install firefox
  </code></pre>