Search code examples
pythonlinuxseleniumpathgeckodriver

python - selenium give error tht geckodriver need to be in PATH (even though IT IS)


So as the title said i try to work with selenium on python i got the geckodriver v0.26.0 for linux 32bit copied it on /usr/local/bin with chmod a+x (for all users):

root@ubuntu:/usr/local/bin# ls -la 
total 6268
drwxr-xr-x  2 root root    4096 May  7 19:23 .
drwxr-xr-x 10 root root    4096 May  3 15:06 ..
-rwxr-xr-x  1 root root 6409830 May  7 19:04 geckodriver

i viewed all previous questions and answers but none of them helped. The error keeps showing : WebDriverException: 'geckodriver' executable needs to be in PATH. i have tried also this line of code :

browser = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')

Solution

  • found the solution for the next one who falls into this problem:

    1. use the compatible geckodriver version (x64 or x86)
    2. copy the file to /usr/local/bin with chmod +x
    3. point to the driver from your code like this :

      browser = webdriver.Firefox(executable_path="/usr/local/bin/geckodriver")