0 votes
1 view
in Devops and Agile by (24.8k points)

I'm new to programming and started with Python about 2 months ago and am going over Sweigart's Automate the Boring Stuff with Python text. I'm using IDLE and already installed the selenium module and the Firefox browser. Whenever I tried to run the webdriver function, I get this:

from selenium import webdriver

browser = webdriver.Firefox()

Exception :-

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0DA1080>>

Traceback (most recent call last):

  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__

    self.stop()

  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop

    if self.process is None:

AttributeError: 'Service' object has no attribute 'process'

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0E08128>>

Traceback (most recent call last):

  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__

    self.stop()

  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop

    if self.process is None:

AttributeError: 'Service' object has no attribute 'process'

Traceback (most recent call last):

  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start

    stdout=self.log_file, stderr=self.log_file)

  File "C:\Python\Python35\lib\subprocess.py", line 947, in __init__

    restore_signals, start_new_session)

  File "C:\Python\Python35\lib\subprocess.py", line 1224, in _execute_child

    startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "<pyshell#11>", line 1, in <module>

    browser = webdriver.Firefox()

  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__

    self.service.start()

  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start

    os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

I think I need to set the path for geckodriver but not sure how, so can anyone tell me how would I do this?

1 Answer

0 votes
by (63k points)

I'm using Windows 10 and this worked for me:

  1. Download geckodriver by navigating to Third Party Drivers, Bindings, and Plugins on the Download option by visiting seleniumhq.org here. Download the right version for the computer you are using

  2. Unzip the file you just downloaded and cut/copy the ".exe" file it contains

  3. Navigate to C:{your python root folder}. Mine was C:\Python27. Paste the geckodriver.exe file in this folder.

  4. Restart your development environment.

  5. Try running the code again, it should work now.

 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...