1

the code:

from selenium import webdriver
driver = webdriver.Firefox(executable_path="Users/M7MD.S.G/AppData/Roaming/Python/Python38/geckodriver.exe")
driver = webdriver.firefox()
driver.get('https://google.com')

I did change the path of geckodriver and restart my pc but its still not working.

the error message:

Traceback (most recent call last):
  File "C:/Users/M7MD.S.G/Desktop/instagrambot/testinggeckodriver.py", line 3, in <module>
    driver = webdriver.Firefox(executable_path="Users/M7MD.S.G/AppData/Roaming/Python/Python38/geckodriver.exe")
  File "C:\Users\M7MD.S.G\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
    self.service.start()
  File "C:\Users\M7MD.S.G\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver.exe' executable needs to be in PATH.
rob.earwaker
  • 1,244
  • 1
  • 7
  • 14

1 Answers1

0

Probably you need to add C: ( considering your users folder is in c drive).

driver = webdriver.Firefox(executable_path=r'C:/Users/M7MD.S.G/AppData/Roaming/Python/Python38/geckodriver.exe')

Note : Its a good practice to mention raw format ( As i put one r before passing executable path).

rahul rai
  • 2,260
  • 1
  • 7
  • 17
  • I have solved it by adding one more / to the path, so the path be like this : (C://Users//M7MD.S.G//AppData//Roaming//Python//Python38//geckodriver.exe) this is working only for windows as I thoght – Mohammed S.G Sep 15 '20 at 20:34