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

后端 未结 5 1747
梦毁少年i
梦毁少年i 2020-12-03 11:01

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

from selenium import webdriver

driver = webdriver.Firefox()
         


        
相关标签:
5条回答
  • 2020-12-03 11:16

    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.

    0 讨论(0)
  • 2020-12-03 11:18

    In addition to the provided answers, there is also this option where you can copy the driver to /usr/bin:

    sudo cp geckodriver /usr/bin 
    
    0 讨论(0)
  • 2020-12-03 11:22

    Selenium is available from the default Ubuntu repositories in Ubuntu 16.04 and later. To install selenium open the terminal and type:

    sudo apt install python-selenium # for Python 2.x
    

    and/or

    sudo apt install python3-selenium # for Python 3.x  
    

    Then type python to start the Python interpreter and from selenium import webdriver should work like this:

    $ python  
    >>> from selenium import webdriver
    

    Assuming that the path ~/.local/bin is in your execution PATH, here's how to install the Firefox webdriver, called geckodriver:

    wget https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz
    tar xvfz geckodriver-v0.20.1-linux64.tar.gz
    mv geckodriver ~/.local/bin
    

    source: https://askubuntu.com/questions/1041541/i-want-to-install-selenium-webdriver-in-my-ubuntu-16-04-system-for-python

    0 讨论(0)
  • 2020-12-03 11:33

    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/
    
    0 讨论(0)
  • 2020-12-03 11:41

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

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

    0 讨论(0)
提交回复
热议问题