50

I've looked around checked both documentations and have found no answer.

I've been trying to use InstaPy a instagram api for python. After failing with multiple errors and assuming InstaPy is just having some issues so i tried to raw code it using selinium. after inserting the example code and alter it to my liking i just made sure this one would work. I received a new error instead of the old one saying the permissions may not be right. I have tried reinstall and running as admin but nothing works. how do i fix this and/or what does this mean

Code:

import time
from selenium import webdriver

driver = webdriver.Chrome('C:\Webdrivers')  # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()

Error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Webdrivers\RawBot.py", line 5, in <module>
    driver = webdriver.Chrome('C:\Webdrivers')  # Optional argument, if not specified will search path.
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 86, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'Webdrivers' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

21 Answers 21

97

This error message...

WebDriverException: Message: 'Webdrivers' executable may have wrong permissions.

...implies that the ChromeDriver variant you are trying to use have wrong permissions.


You seem to have tried out:

driver = webdriver.Chrome('C:\Webdrivers')  # Optional argument, if not specified will search system $PATH variable.

A few words:

  • If your underlying is :

    • You have to download chromedriver_win32.zip from the ChromeDriver Download Location and unzip it for usage.
    • Additionally, if you are explicitly specifying the Chromedriver binary path you have to append the binary extension as well, effectively i.e. chromedriver.exe.
    • While mentioning the Chromedriver binary path you have to either use the single forward slash i.e. (/) along with the raw (r) switch or you have to use the escaped backslash i.e. (\\).
    • So your effective line of code will be :

      driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
      
  • If your underlying is :

    • You have to download chromedriver_linux64 from the ChromeDriver Download Location and untar it for usage.
    • Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.
    • While mentioning the Chromedriver binary path you have to use the single forward slash i.e. (/).
    • So your effective line of code will be :

      driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
      
  • If your underlying is :

    • You have to download chromedriver_mac64 from the ChromeDriver Download Location and untar it for usage.
    • Additionally, if you are explicitly specifying the Chromedriver binary path you don't have to provide any extension for the executable binary, effectively i.e. chromedriver.
    • While mentioning the chromedriver binary path you have to use the single forward slash i.e. (/).
    • So your effective line of code will be :

      driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
      
1
  • 3
    on windows 10 & python 3.7.1 I didn't need the raw (r) switch. Also didn't need the 'executable_path=' Not entirely sure why, link below indicates os.path.normpath corrects this. It's possible this practice has been included in webdriver.Chrome() pythonconquerstheuniverse.wordpress.com/2008/06/04/… Commented Apr 11, 2019 at 1:29
25

This got solved when you enter the full file name which is "chromedriver.exe". Try this if you are on windows

2
  • 8
    What about Ubuntu?
    – Mostafa
    Commented Feb 5, 2019 at 9:18
  • 4
    @Mostafa chromedriver, without the .exe
    – Snow
    Commented Apr 23, 2020 at 15:23
8

You just have to add

/chromedriver.exe

at the end of the path like this:

driver = webdriver.Chrome('C:/Users/User/Downloads/chromedriver_win32/chromedriver.exe')

Note: If you copy the path from "File Explorer" you will get:

C:\Users\User\Downloads\chromedriver_win32

You will need to use double backslashes like this:

C:\\Users\\User\\Downloads\\chromedriver_win32

so you don't get a syntax error. Or you can just use forward slashes.

7

If you are on a linux os, changing file permissions could possibly fix the problem. But beware of what you do with permissions:

chmod 755 "/path to chromedriver file"

I downloaded the file via python itself, which unfortunately disabled execution permission and this was the quick fix for it.

4

in Linux you need to specify the FULL path including the file itself as well, not just up to the folder (in Linux by default the downloaded file for chrome driver comes in a folder, e.g. 'chromedriver_linux64', open the folder and check the exact file name as well, usually 'chromedriver'):

from selenium import webdriver
chrome_driver_path = "/home/mn/chromedriver_linux64/chromedriver"
driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.get("https://www.amazon.com")
1
  • 1
    This reply hasn't got as attention it should have. Thanks!
    – milia
    Commented Oct 8, 2022 at 20:52
2

if you are using chrome you must specify the full path of the chromedriver. search for the directory in which your chromedriver executable file resides. click shift+right click on the executable file. select "copy as path" and paste it in your script. don't forget to use a double backslash

so it should be:

driver = webdriver.Chrome('C:\\Utility\\BrowserDrivers\\chromedriver.exe')
2

If you use a Mac OS Big Sur, and Chromedriver 90+, you might have an error with the permissions of your Chromedriver.

If this is the case, it's not the file permissions that you change via "chmod," instead, it is apple-store protection that forbids the execution of the web driver.

If you like to allow this driver to be used within your Python environment or via command-line, enter:

`$ sudo xattr -r -d com.apple.quarantine  /usr/local/bin/chromedriver`
2

chmod 755 "/path to chromedriver file"

This has helped me

1

had same issue in django.

However when I ran the same code locally (not activating my django app) it was fine and didn't have to explicitly define the path to the chrome driver.

Got around it by explicitly defining the path and the chromederiver.exe

similar to the answer above. path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"

in my case, since I want to eventually post my app I used dynamic paths

ie.

import os

BASE_oaAPP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_oaAPP_Utilities_DIR  = os.path.join(BASE_oaAPP_DIR, 'mySubFolderInTheApp')

def utilsPathFileName(fileName):
    return os.path.join(BASE_oaAPP_Utilities_DIR, fileName)

chrome_path = utilsPathFileName('chromedriver.exe')
driver = webdriver.Chrome(chrome_path)
1

WINDOWS : Giving complete file path solved problem.

Many tutorials and articles are recorded with previous versions, where you just give directory path containing web drivers. But now you also have to provide specific driver path you're using.

Instead of C:/WebDrivers give complete file path as C:/WebDrivers/chromedriver.exe

1

The same problem. My solution was in Linux os, Pycharm editor...

  1. Make sure your webdriver file with other python files (such as selinum_driver.py)
  2. Then just copy the path and paste it into your webdriver.Chrome('path')
  3. Don't need to write webdriver.exe

driver = webdriver.Chrome('/home/raju/Documents/Python-selenium/chromedriver')

1

For WINDOWS 10: I ran into a similar situation with the same error message when running my test code in Visual Studio Code. What solved it for me was to close out of the VS Code app and re-open the app as an administrator via the right-click menu.

0

For me, none of the answers above worked. But moving the chromedriver.exe to a new path (desktop in my case) solved it.

path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
0

I got the same error when wrongly installed drives(when for mac was downloaded windows drivers) once I correct it worked fine

0

You need to add exe at the end of the path of driver and it works.

0

locate your installed driver.exe, shift+right click, copy as path, paste it to your IDE

0

we can fix this issue for centos

#Install package chromedriver. Install it using yum    
yum install chromedriver

#Import following package in python.
from selenium import webdriver

#Add following options before initializing the webdriver
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("--headless")
chromeOptions.add_argument("--remote-debugging-port=9222")
chromeOptions.add_argument('--no-sandbox')
driver = webdriver.Chrome('/usr/bin/chromedriver',chrome_options=chromeOptions)
0

If you run it on a Windows computer you can also add it to Windows PATH (environment variables) so you don't have to declare executable_path. You can just say: webdriver.Chrome(options=your_options)

0

I got his error for MacOs and on changing the path to the one given below, the issue was solved.

driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
2
  • 1
    Can you expand on why you think this solves the problem?
    – DMart
    Commented Jan 25, 2021 at 22:20
  • I was initially using executable path = path, as chromedriver was already installed in the project path. I got error for that. On checking the Chromedriver [chromedriver.chromium.org/getting-started] docs, it was mentioned that the notation for selecting path is different for different programming languages as well as the extensions. eg, in windows it ends with .exe, but in Mac, it does not
    – Abhishmita
    Commented Feb 8, 2021 at 17:07
0

Windows users and visual studio code: while mentioning the Chromedriver binary path you have to either use the single forward slash i.e. (/) along with the raw (r) switch or you have to use the escaped backslash i.e. (\). as well use the exact path and add chromedriver.exe at the end of the path to point directly to the executable:

driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')

or:

driver = webdriver.Chrome(r'C:\\Users\\wanja\\Downloads\\Compressed\\chromedriver_win32\\chromedriver.exe')
0

this error means that file chromedriver is not executable, I fix this error with run command of (in linux):

sudo chmod +777 chromedriver

It means to make the file executable by everyone with access.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Aug 22, 2022 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.