Selenium on MAC, Message: 'chromedriver' executable may have wrong permissions

The error says it all :

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

The error clearly mentions that the chromedriver which is getting detected have wrong permissions.


Solution

  • Download the latest chromedriver binary from ChromeDriver - WebDriver for Chrome and save it in your system.
  • Ensure that chromedriver binary have the required permissions.
  • While initiating the WebDriver and WebClient pass the argument executable_path along with the absolute path of the chromedriver binary as follows :

    from selenium import webdriver
    
    link = "https://accounts.google.com"
    driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
    driver.get(link)
    

Reference

You can find a detailed relevant discussion in:

  • 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Most answers here and in other related posts suggest users to just move the file to /usr/bin and they work fine if you are just running chromedriver locally and normally.

However, if you are compiling Python scripts into executables using compilers such as cx_freeze, you may not be able to afford the luxury if your program always uses a relative link to chromedriver.

As the error message suggests, your compiled program does not have the permissions to manipulate chromedriver. To use a relative link to chromedriver on a Mac in your compiled Python program, you can programmatically change the permission of chromedriver in your Python script using:

import os
os.chmod('/path/to/chromedriver', 0755) # e.g. os.chmod('/Users/user/Documents/my_project/chromedriver', 0755)

You can test this by doing the following:

  1. cd to your working directory

  2. $ chmod 755 chromedriver to allow your program to manipulate it

P.S. 755 is the default numerical permission for files in usr/bin. 664 is the default numerical permission for files in other normal folders (probably your working directory). Thus, when chromedriver complains it does not have the correct permission, you need to grant it a numerical permission equivalent to or greater than 755.


If you are on windows give path including file name. For example, './chromedriver/chromedriver.exe' My line of code looks like below.

service = webdriver.chrome.service.Service('./chromedriver/chromedriver.exe')