Selenium using Python – Geckodriver executable needs to be in PATH

| | | | | | |

👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!

I"m new to programming and started with Python about two 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:PythonPython35libsite-packagesseleniumwebdrivercommonservice.py", line 163, in __del__
    self.stop()
  File "C:PythonPython35libsite-packagesseleniumwebdrivercommonservice.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:PythonPython35libsite-packagesseleniumwebdrivercommonservice.py", line 163, in __del__
    self.stop()
  File "C:PythonPython35libsite-packagesseleniumwebdrivercommonservice.py", line 135, in stop
    if self.process is None:
AttributeError: "Service" object has no attribute "process"
Traceback (most recent call last):
  File "C:PythonPython35libsite-packagesseleniumwebdrivercommonservice.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:PythonPython35libsubprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:PythonPython35libsubprocess.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:PythonPython35libsite-packagesseleniumwebdriverfirefoxwebdriver.py", line 135, in __init__
    self.service.start()
  File "C:PythonPython35libsite-packagesseleniumwebdrivercommonservice.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 I am not sure how, so how would I do this?

👻 Read also: what is the best laptop for engineering students?

Selenium using Python - Geckodriver executable needs to be in PATH __del__: Questions

How can I make a time delay in Python?

5 answers

I would like to know how to put a time delay in a Python script.

2973

Answer #1

import time
time.sleep(5)   # Delays for 5 seconds. You can also use a float value.

Here is another example where something is run approximately once a minute:

import time
while True:
    print("This prints once a minute.")
    time.sleep(60) # Delay for 1 minute (60 seconds).

2973

Answer #2

You can use the sleep() function in the time module. It can take a float argument for sub-second resolution.

from time import sleep
sleep(0.1) # Time in seconds

Selenium using Python - Geckodriver executable needs to be in PATH __del__: Questions

How to delete a file or folder in Python?

5 answers

How do I delete a file or folder in Python?

2639

Answer #1


Path objects from the Python 3.4+ pathlib module also expose these instance methods:

What is the difference between os.path.basename() and os.path.dirname()?

1 answers

What is the difference between os.path.basename() and os.path.dirname()?

I already searched for answers and read some links, but didn"t understand. Can anyone give a simple explanation?

158

Answer #1

Both functions use the os.path.split(path) function to split the pathname path into a pair; (head, tail).

The os.path.dirname(path) function returns the head of the path.

E.g.: The dirname of "/foo/bar/item" is "/foo/bar".

The os.path.basename(path) function returns the tail of the path.

E.g.: The basename of "/foo/bar/item" returns "item"

From: http://docs.python.org/3/library/os.path.html#os.path.basename

We hope this article has helped you to resolve the problem. Apart from Selenium using Python – Geckodriver executable needs to be in PATH, check other __del__-related topics.

Want to excel in Python? See our review of the best Python online courses 2022. If you are interested in Data Science, check also how to learn programming in R.

By the way, this material is also available in other languages:



Javier Chamberlet

Texas | 2022-11-28

basename is always a bit confusing 😭 Selenium using Python – Geckodriver executable needs to be in PATH is not the only problem I encountered. I am just not quite sure it is the best method

Julia Ungerschaft

Shanghai | 2022-11-28

Simply put and clear. Thank you for sharing. Selenium using Python – Geckodriver executable needs to be in PATH and other issues with find was always my weak point 😁. I just hope that will not emerge anymore

Dmitry Jackson

Abu Dhabi | 2022-11-28

Maybe there are another answers? What Selenium using Python – Geckodriver executable needs to be in PATH exactly means?. Will get back tomorrow with feedback

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically