Python Forum
Selenium error with ebdriver (geckodriver)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selenium error with ebdriver (geckodriver)
#1
Hi, All!

I am using this code:

Quote:from selenium import webdriver
nav = webdriver.Firefox()

But, I am getting the following error:

Quote:/home/martinelli/PycharmProjects/ESAB/venv/bin/python /home/martinelli/PycharmProjects/ESAB/LogaSGE.py
Traceback (most recent call last):
File "/home/martinelli/PycharmProjects/ESAB/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/martinelli/PycharmProjects/ESAB/LogaSGE.py", line 5, in <module>
nav = webdriver.Firefox()
File "/home/martinelli/PycharmProjects/ESAB/venv/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/home/martinelli/PycharmProjects/ESAB/venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

Process finished with exit code 1

I have installed PYCharm Community 2019.2.2. It is Python 3.7. I am using Debian 10 (Buster). I have changed the permission from the / with rmx to all users, directories and files, in case, "geckodriver". Also, I have inserted "geckodriver" and its PATH on the enviromnent PATH, and, also, to the "Interpreter Paths".

But it keeps giving this error.

Has Anyone any ideia what I can do?
Reply
#2
Quote:I have changed the permission from the / with rmx to all users, directories and files, in case, "geckodriver". Also, I have inserted "geckodriver" and its PATH on the enviromnent PATH, and, also, to the "Interpreter Paths".
You should not need to do any of that. The only odd thing might be PyCharm specific.

just copy geckodriver to your /usr/local/bin

example:
metulburr@ubuntu:~$ cat test11.py
from selenium import webdriver
nav = webdriver.Firefox()
metulburr@ubuntu:~$ python3 test11.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "/usr/local/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test11.py", line 2, in <module>
    nav = webdriver.Firefox()
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__
    self.service.start()
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 81, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 
metulburr@ubuntu:~$ mv /home/geckodriver /usr/local/bin
mv: cannot move '/home/geckodriver' to '/usr/local/bin/geckodriver': Permission denied
metulburr@ubuntu:~$ sudo !!
sudo mv /home/geckodriver /usr/local/bin
[sudo] password for metulburr:
metulburr@ubuntu:~$ python3 test11.py
metulburr@ubuntu:~$ 
you could also just set the path directly
driver = webdriver.Firefox(executable_path='your\path\geckodriver')
Recommended Tutorials:
Reply
#3
Thanks!!!

I moved geckodriver to /usr/local/bin/, and, also, insert the line as you said. And I changed again, the permissions to 777 only for the file.

nav = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
It worked! Thanks, again!!!
Reply
#4
(Sep-23-2019, 01:40 AM)Martinelli Wrote: I moved geckodriver to /usr/local/bin/, and, also, insert the line as you said.
You dont need both. You would only need one or the other. You dont need the path at all if you put geckdriver in /usr/local/bin. Whereas if you did not, you can simply put the path as an argument
Recommended Tutorials:
Reply
#5
Ok! Thanks for that tip! Nice again!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium weird error julio2000 0 1,646 Feb-23-2020, 01:24 PM
Last Post: julio2000
  Selenium webdriver error WiPi 4 11,986 Feb-09-2020, 11:38 AM
Last Post: WiPi
  error when running headless selenium julio2000 2 4,508 Feb-01-2020, 12:41 PM
Last Post: julio2000
  Error clicking button with selenium julio2000 4 5,250 Jan-06-2020, 10:59 AM
Last Post: julio2000
  Python Selenium .click() Loads Error - Works Manually.- Events not Triggered NSearch 24 11,526 Aug-14-2019, 02:23 PM
Last Post: NSearch
  Error when trying to use Selenium ejected 1 5,144 Mar-26-2019, 04:53 AM
Last Post: ejected
  Instagramlogin Error (Selenium) julian_veit 0 2,618 Jan-26-2019, 02:40 PM
Last Post: julian_veit
  selenium error : evilcode1 7 5,098 Nov-12-2018, 01:08 PM
Last Post: snippsat
  Getting error when accessing elements in a modal window of an webpage using selenium sumandas89 3 8,574 Jul-13-2018, 10:44 AM
Last Post: mlieqo
  Python 3/selenium - nontype error water_fox 2 11,747 Jun-28-2018, 08:19 PM
Last Post: Sudhakar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020