Home > database >  ubuntu: 'geckodriver' executable needs to be in PATH
ubuntu: 'geckodriver' executable needs to be in PATH

Time:05-27

I have firefox installed and geckodriver.exe in the same directory. The same code works in windows but when i try to use it in ubuntu i have the following error: 'geckodriver.exe' executable needs to be in PATH.

the code is the following:

import time
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

url = 'https://www.idealista.com/venta-viviendas/barcelona/eixample/la-dreta-de-l-eixample/?ordenado-por=fecha-publicacion-desc'
options = Options()
options.headless = False
driver = webdriver.Firefox(options=options, executable_path=r'geckodriver')
driver.get(url)
time.sleep(10)

i've tried using the same code without calling gecko with r: driver = webdriver.Firefox(options=options, executable_path='geckodriver')

CodePudding user response:

You can use webdriverManager, it's up-to-date and no need binary driver extension.So it will never show the error like you are getting:geckodriver.exe' executable needs to be in PATH. You have to install selenium4 and pip install webdriver-manager

#selenium4
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.options import Options

driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()),options=options)


url = 'https://www.idealista.com/venta-viviendas/barcelona/eixample/la-dreta-de-l-eixample/?ordenado-por=fecha-publicacion-desc'
options = Options()
options.headless = False
driver.get(url)
time.sleep(10)

webdriverManager

CodePudding user response:

Using the complete path solved the problem

import time    
from selenium import webdriver    
from selenium.webdriver.firefox.options import Options      
url = 'https://www.idealista.com/venta-viviendas/barcelona/eixample/la-dreta-de-l-eixample/?ordenado-por=fecha-publicacion-desc'    
options = Options()    
options.headless = False    
driver = webdriver.Firefox(options=options, executable_path='/home/kevin/Desktop/Inmosoft/geckodriver')    
driver.get(url)    
time.sleep(10)
  • Related