Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Selenium in Ubuntu OSError: [Errno 20] Not a directory

After installing Selenium in Ubuntu and adding geckodriver to path I get this error when I run

from selenium import webdriver

driver = webdriver.Firefox()

error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 20] Not a directory

What's going on?

EDIT: Solved using chromedriver instead of geckodriver.

like image 559
User Avatar asked Oct 16 '16 17:10

User


3 Answers

Had the same problem. There were two ways to fix this for me:

Add executable_path arg in webdriver:

driver = webdriver.Firefox(executable_path='/path/to/geckodriver')

And the second way its to add folder that contains geckodriver using export (only folder, not geckodriver):

$ export PATH=$PATH:/path/to/
like image 94
Poloq Avatar answered Nov 12 '22 06:11

Poloq


In addition to the answer by @Poloq, the simplest way would be keeping your geckodriver binary in a directory which is already in your PATH.

mv geckodriver /usr/local/bin

This way you can avoid additional settings/configurations in your project with the downside of having an additional step when deploying on different systems.

like image 20
dsalaj Avatar answered Nov 12 '22 06:11

dsalaj


The problem is that you renamed "geckodriver" to "wires".

The solution is to add "geckodriver" to search path then it should work.

like image 1
Kamil W. Avatar answered Nov 12 '22 05:11

Kamil W.