How to install geckodriver?

I am trying to work with Selenium in Python. However, I do not know what to do, given the below at https://pypi.python.org/pypi/selenium

Selenium requires a driver to interact with the selected browser. For example, Firefox requires a geckodriver , which must be installed before running the examples below. Make sure it is listed in your PATH, for example, put it in /usr/bin or/usr/local/bin .

I am using Windows 7 32bit. I found geckodriver here: https://github.com/mozilla/geckodriver/releases

I mainly used the Anaconda Python distribution to work with Excel, so I don't know what PATH is.

Thanks,

UPDATE :

I updated PATH as shown in the comments. Here is a complete error tracing.

Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C: \ Users \ user1> python

Python 3.5.2 | Anaconda 4.2.0 (32-bit) | (default, July 5, 2016 11:45:57) [MSC v.1 900 32 bit (Intel)] on win32

Enter โ€œhelp,โ€ โ€œcopyright,โ€ โ€œcredits,โ€ or โ€œlicenseโ€ for more information.

 from selenium import webdriver driver = webdriver.Firefox() 

Traceback (last call last):

File "", line 1, in

File "C: \ Users \ user1 \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ site -packages \ selenium-2.53.6-py3.5.egg \ selenium \ webdriver \ firefox \ webdriver.py", li ne 80, in init self.binary, timeout)

File "C: \ Users \ user1 \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ site -packages \ selenium-2.53.6-py3.5.egg \ selenium \ webdriver \ firefox \ extension_connect ion.py", line 52, in init self.binary.launch_browser (self.profile, timeout = timeout)

File "C: \ Users \ user1 \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ site -packages \ selenium-2.53.6-py3.5.egg \ selenium \ webdriver \ firefox \ firefox_binary.py", line 67, in launch_browser self._start_from_profile_path (self.profile.path)

File "C: \ Users \ user1 \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ site -packages \ selenium-2.53.6-py3.5.egg \ selenium \ webdriver \ firefox \ firefox_binary.py", line 90, in _start_from_profile_path env = self._firefox_env)

File "C: \ Users \ user1 \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ subp rocess.py", line 947, in init restore_signals, start_new_session)

File "C: \ Users \ user1 \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ subp rocess.py", line 1224, in _execute_child startupinfo)

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

+17
source share
5 answers
  1. You can download geckodriver
  2. unpack it
  3. Copy this .exe file and put it in the python parent folder (e.g. C:\Python34 )
  4. write your scripts.

This will succeed.

+13
source

Some options, select 1:

  • Move the exe file to a folder in the PATH environment variable.
  • Update PATH to have a directory containing exe.
  • Explicitly override os.environ["webdriver.gecko.driver"]

basically drag the geckodriver somewhere where you have your executables, you should then open a command prompt and use it.

/bin on linux and C:\Program Files

cm

in particular, explanations about how the driver can be seen, where he can be put, and how to change the way selenium is searched.

+1
source

The easiest way if you are on windows:

 driver = webdriver.Firefox(executable_path=r'[Your path]\geckodriver.exe') 

Example:

 driver = webdriver.Firefox(executable_path=r'D:\geckodriver.exe') 
+1
source

For Python 3, the Selenium plus web driver for Firefox;

  1. Open Command Prompt
  2. Type Pip install -U Selenium (-U will upgrade it to the latest version of Selenium.) This selenium example is already installed

  3. Go to https://github.com/mozilla/geckodriver/releases.

  4. At the time of writing, I selected the latest version, which was just the version indicated at the top of the page. For me it was v0.24.0.

  5. Scroll down to resources, and then click and download the driver you need. For Windows, it will be a ZIP file. Most likely 64bit. Download the web driver by clicking on link 5. Right-click on the downloaded file and unzip the file.

  6. Copy and paste the file somewhere in the python directory. For example, if I installed Python in C: \ Python \ Python37, I would insert a file there so that gecko is in C: \ Python \ Python37 \ geckodriver-v0.24.0-win64.

Copy the path to the hex driver file

  1. Inside this folder that you just copied will be geckodriver.exe

  2. In Windows 10, click the "Windows" button and look for "environment variables." Find environment variables OR find them using these instructions; https://www.computerhope.com/issues/ch000549.htm

  3. Click on the "environment variables" field in the lower right corner.

  4. In the bottom "System Variables" field, highlight the "Path" variable as follows. Adding a Path environment variable

  5. Click edit, and then add an entry at the bottom of the list. Copy and paste the folder in which the geckodriver.exe file is located. For me it was C: \ Python \ Python37 \ geckodriver-v0.24.0-win64 (or where you copied the file in step 6) Adding a gecko to Windows PATH

0
source

This worked for me (Windows 10, Firefox browser):

 from selenium import webdriver driver = webdriver.Firefox(executable_path=r'C:\......YOUR_PATH.......\geckodriver.exe') driver.get('http://EXAMPLE_URL.com') 
0
source

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


All Articles