title: executable is in path but is not found by selenium in docker frolvlad/alpine-python3
body: <p>I'm trying to run selenium in an alpine docker. I allready managed it <code>FROM python:3</code> but it would be nice to save that disk space.</p>
  
  <p>I get the error<br>
  <code>selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.</code><br>
  and <code>FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'</code><br>
  Googling this only gives <em>"Put geckodriver in your $PATH"</em> and <em>"Add folder path of geckodriver to $PATH with PATH=$PATH:/usr/src/app"</em></p>
  
  <p>But <code>geckodriver</code> is in $PATH and it still results in the same error.  </p>
  
  <p>I also tried adding the executable as argument to the <code>driver = webdriver.Firefox()</code> but it changed nothing.<br>
  <em>WebDriverException: 'geckodriver' executable needs to be in PATH even though it is (1 answer)<br>
  selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH with GeckoDriver Selenium Firefox (2 answers)<br>
  Python 3.5 - “Geckodriver executable needs to be in PATH” (4 answers)</em></p>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM frolvlad/alpine-python3
  WORKDIR /usr/src/app
  COPY . .
  RUN tar -xzf geckodriver-v0.26.tar.gz &amp;&amp; cp geckodriver /bin
  
  RUN pip install --no-cache-dir -r requirements.txt
  RUN apk add --no-cache firefox-esr xvfb
  ENV DISPLAY=:1.0
  
  ENTRYPOINT ["./entrypoint.sh"]
  </code></pre>
  
  <p>entrypoint.sh</p>
  
  <pre class="lang-sh prettyprint-override"><code>Xvfb :1 -screen 0 1024x768x16 &amp;&gt; xvfb.log &amp;
  python ./seleniumTest.py
  </code></pre>
  
  <p>output:</p>
  
  <pre class="lang-sh prettyprint-override"><code>/usr/src/app # echo $PATH
  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/src/app:/usr/src/app
  /usr/src/app # which geckodriver
  /bin/geckodriver
  /usr/src/app # type geckodriver
  geckodriver is /bin/geckodriver
  /usr/src/app # ls -l /bin/geckodriver
  -rwxr-xr-x    1 root     root       7008696 Mar  3 18:29 /bin/geckodriver
  /usr/src/app # ./entrypoint.sh
  xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!
  Traceback (most recent call last):
    File "/usr/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
      self.process = subprocess.Popen(cmd, env=self.env,
    File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "./seleniumTest.py", line 8, in &lt;module&gt;
      driver= webdriver.Firefox()
    File "/usr/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
      self.service.start()
    File "/usr/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
      raise WebDriverException(
  selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
  </code></pre>
  
  <p>seleniumTest.py:</p>
  
  <pre class="lang-py prettyprint-override"><code>from pyvirtualdisplay import Display
  from selenium import webdriver
  
  display = Display(visible=0, size=(1024, 768))
  display.start()
  
  url = 'https://stackoverflow.com/questions/15018372/how-to-take-partial-screenshot-with-selenium-webdriver-in-python'
  driver= webdriver.Firefox()
  
  driver.get(url)
  
  element = driver.find_element_by_css_selector('#question-header')
  image = element.screenshot('screenshot.png')
  </code></pre>