Error message: “'chromedriver' executable needs to be available in the path”

前端 未结 25 1856
轻奢々
轻奢々 2020-11-22 05:15

I am using selenium with python and have downloaded the chromedriver for my windows computer from this site: http://chromedriver.storage.googleapis.com/index.html?path=2.15/

相关标签:
25条回答
  • 2020-11-22 05:54

    Add the webdriver(chromedriver.exe or geckodriver.exe) here C:\Windows. This worked in my case

    0 讨论(0)
  • 2020-11-22 05:55

    Before you add the chromedriver to your path, make sure it's the same version as your browser.

    If not, you will need to match versions: either update/downgrade you chrome, and upgrade/downgrade your webdriver.

    I recommend updating your chrome version as much as possible, and the matching the webdriver.

    To update chrome:

    • On the top right corner, click on the three dots.
    • click help -> About Google Chrome
    • update the version and restart chrome

    Then download the compatible version from here: http://chromedriver.chromium.org/downloads .

    Note: The newest chromedriver doesn't always match the newest version of chrome!

    Now you can add it to the PATH:

    1. create a new folder somewhere in your computer, where you will place your web drivers. I created a folder named webdrivers in C:\Program Files

    2. copy the folder path. In my case it was C:\Program Files\webdrivers

    3. right click on this PC -> properties:

    1. On the right click Advanced System settings
    2. Click Environment Variables
    3. In System variables, click on path and click edit
    4. click new
    5. paste the path you copied before
    6. click OK on all the windows

    Thats it! I used pycharm and I had to reopen it. Maybe its the same with other IDEs or terminals.

    0 讨论(0)
  • 2020-11-22 05:55

    (for Mac users) I have the same problem but i solved by this simple way: You have to put your chromedriver.exe in the same folder to your executed script and than in pyhton write this instruction :

    import os

    os.environ["PATH"] += os.pathsep + r'X:/your/folder/script/'

    0 讨论(0)
  • 2020-11-22 05:56

    Had this issue with Mac Mojave running Robot test framework and Chrome 77. This solved the problem. Kudos @Navarasu for pointing me to the right track.

    $ pip install webdriver-manager --user # install webdriver-manager lib for python
    $ python # open python prompt
    

    Next, in python prompt:

    from selenium import webdriver
    from webdriver_manager.chrome import ChromeDriverManager
    driver = webdriver.Chrome(ChromeDriverManager().install())
    
    # ctrl+d to exit
    

    This leads to the following error:

    Checking for mac64 chromedriver:xx.x.xxxx.xx in cache
    There is no cached driver. Downloading new one...
    Trying to download new driver from http://chromedriver.storage.googleapis.com/xx.x.xxxx.xx/chromedriver_mac64.zip
    ...
    TypeError: makedirs() got an unexpected keyword argument 'exist_ok'
    
    • I now got the newest download link
      • Download and unzip chromedriver to where you want
      • For example: ~/chromedriver/chromedriver

    Open ~/.bash_profile with editor and add:

    export PATH="$HOME/chromedriver:$PATH"
    

    Open new terminal window, ta-da

    0 讨论(0)
  • 2020-11-22 05:58

    I encountered the same problem as yours. I'm using PyCharm to write programs, and I think the problem lies in environment setup in PyCharm rather than the OS. I solved the problem by going to script configuration and then editing the PATH in environment variables manually. Hope you find this helpful!

    0 讨论(0)
  • 2020-11-22 06:00

    Check the path of your chrome driver, it might not get it from there. Simply Copy paste the driver location into the code.

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