[Solved] selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH

While you have installed Selenium and trying to import webdriver from It. Then you will face selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH, this error.

In this article, you’ll learn everything about this selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH Error in Python. And how to resolve the error all the possible solutions with examples.

How selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH Error Occurs?

Most of the time you get this error While you have installed Selenium and trying to import webdriver from It. then you will face this error like this below.

How To Fix selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH Error?

There are different ways to fix selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH this error. Let us take a look at every solution.

  • How To Solve selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH Error?

To fix this selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH Error First you just to install webdriver-manager with this command: pip install webdriver-manager. After you install webdriver-manager package, You can import GeckoDriverManager by running this code: from webdriver_manager.firefox import GeckoDriverManager And then install it: driver = webdriver.Firefox(executable_path=GeckoDriverManager().install()) And you can use firefox browser without manually any coding. Now, I hope your error will be solved.

  • selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH

To fix this selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH Error You want to use Firefox From selenium then you have to download geckodriver and Add its path In Your Code. First Download geckodriver And then Extract it your geckodriver.exe file. Then You have to copy its path whenever geckodriver.exe file saved. paste This path in this executable_path. webdriver.Firefox(executable_path=r’your\path\geckodriver.exe’) And now You can run Firefox without any error.

Solution 1: Use webdriver-manager

First of all install webdriver-manager with this below the command:

pip install webdriver-manager

Now, You can import GeckoDriverManager with this code.

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

And then install it.

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

And you can use firefox browser without manually any coding.

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

driver.get('https://google.com')

Now, Your error will be solved.

Solution 2: Add Firefox executable_path

When You Want to use Firefox From selenium then You have to download geckodriver and Add its path In Your Code.

  1. First Download geckodriver.
  2. and You can See there is geckodriver.exe file Now Extract it.
  3. Then You have to copy its path whenever geckodriver.exe file saved.
  4. paste This path in this executable_path.
  5. webdriver.Firefox(executable_path=r’your\path\geckodriver.exe’)
  6. And now You can run Firefox without any error.
from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
driver.get('https://google.com')

Now, I hope your error will solved

Conclusion

In this article, we have discussed what causes the error and we have discussed ways to fix the error.

we hope this article has been informative. Thank you for reading. Kindly comment and let us know if you found it helpful.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Categories