WholesomeGhost
WholesomeGhost

Reputation: 1121

Error while importing selenium on Ubuntu

So as it says in the title I have a problem with importing Selenium module on my Ubuntu laptop. On my Windows pc everything goes fine with basic Selenium code:

from selenium import webdriver
driver = webdriver.Firefox()

but when I try to do that on my Ubuntu machine I get an error that is basically saying:

os.path.basename(self.path), self.start_error_message)
selenium.common.exception.WebDriverException:  Message:'geckodriver'executable needs to be in PATH.

Has anyone encoutered this problem and if yes does anyone know how to fix it?

Upvotes: 1

Views: 119

Answers (1)

Connor
Connor

Reputation: 698

An easy way to fix this is to download the driver from here: https://github.com/mozilla/geckodriver/releases

Method 1: Adding geckodriver to existing path folder

Unzip the file and copy the "geckodriver" executable to "/usr/bin" using:

cd /folder/containing/geckodriver
sudo cp geckodriver /usr/bin

Method 2: Adding custom geckodriver location to path

You can also add the driver in your system path temporarily with:

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

For a permanent solution, you can edit your bash profile with:

gedit ~/.profile

Then find the PATH line and modify it to look more like this:

PATH="$HOME/bin:$PATH:/path/to/geckodriver"

Upvotes: 1

Related Questions