How to put geckodriver in PATH?

I am on OS Sierra and I am running Python 3.5.2. I have selenium installed, and I'm following a book called Automating Boring Tasks Using Python

My code

from selenium import webdriver >>> browser = webdriver.Firefox() 

I keep getting an error

 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 64, in start stdout=self.log_file, stderr=self.log_file) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1551, 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 "<pyshell#1>", line 1, in <module> browser = webdriver.Firefox() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__ self.service.start() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/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 searched for a lot of solutions to solve my problem. Many people have the same problem .. but none of the solutions work. I have a geckodriver copied everywhere in Python folders. I tried using the terminal and I tried to specify the path in the code and it still gives me errors. Hope someone can help me. I apologize if this is the wrong format, I don’t know what I'm doing.

+6
source share
3 answers

I had the same problem, and here is how I fixed it:

  • Download geckodriver from here
  • Extract and unzip and move the geckodriver file to the /usr/local/bin/
  • Run python program with selenium Firefox webdriver.
+11
source

This answer can be easily solved by searching on Google "add the program to the path"

 export PATH=$PATH:/path/to/geckodriver 
0
source

"I have a geckodriver copied everywhere in Python folders." Make sure the geckodriver executable is found in one of the paths at startup:

 import sys print sys.path 

And the problem must be solved.

0
source

Source: https://habr.com/ru/post/1011959/


All Articles