WebDriverException: Message: ‘Webdrivers’ executable may have wrong permissions. In Python

WebDriverException: Message: ‘Webdrivers’ executable may have wrong permissions. In Python is an error that occurs when the ChromeDriver has wrong permissions.

In this article, I am going to detail exactly why this error is happening and how you can avoid it, I am also going to present the solution that worked for me and other possible solutions that worked for developers who faced the same issue.

Describing WebDriverException: Message: ‘Webdrivers’ executable may have wrong permissions. In Python

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 selenium. 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

I was running some automation code I wrote with Selenium and started getting some errors, After solving those error I thought everything was fine, suddenly I got another error.

The error says, the permissions are not right, I figured I would remove Selenium and everything will work fine, instead I got the same error again.

I tried uninstalling and installing again, I tried upgrading and nothing worked. This is the error code

                                                                       #
Traceback (most recent call last):
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
    driver = webdriver.Chrome('C:\Webdrivers')  # Optional argument, if not specified will search path.
    self.service.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
                                                                       #

After hours of research I managed to solve the problem, today I am sharing with you the solution that worked for me and other solutions that worked for other developers.

Solution 1 : Specify the Chromedriver binary path and append the binary extension chromedriver.exe

I am a windows user, so the first solution is going to be for fellow windows users, but do not worry, If you are a Linux user the second solution is for you and if you are a Mac user please check out the third solution.

The error in most cases is caused around this line of code, this code needs to be changed, but that is only one step.

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

Please follow the instructions Step by Step.

Step 1 : Download chromedriver_win32.zip then Unzip it.

Step 2 : Specify the Chromedriver binary path and append the binary extension chromedriver.exe as well.

Step 3 : In your code, only use the single forward slash / along with the r

Your line of code should look like this :

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

The error should be gone, if this solution worked for you, please consider donating to our team using the red Kofi button above. For Linux users try the solution bellow.

Solution 2 : Download and install chromedriver_linux64

Please follow the instructions bellow Step by Step.

Step 1 : Download chromedriver_linux64 then Untar it.

Step 2 : Specify the Chromedriver binary path and DO NOT append the binary extension, just like this chromedriver.

Step 3 : In your code, only use the single forward slash /.

Your line of code should look like this :

                                                                       #
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
                                                                       #

I hope you followed these steps until solving the error, If you are a MacOs user please follow the solution bellow.

Solution 3 : Download and install chromedriver_mac64

Please follow the following instructions Step by Step.

Step 1 : Download chromedriver_mac64 then Untar it.

Step 2 : You can Specify the Chromedriver binary path and DO NOT append the binary extension, exactly like this chromedriver.

Step 3 : Only use the single forward slash / in your code.

The important line of code should look like this :

                                                                       #
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
                                                                       #

Summing-up

This is the end of this article guys, I hope one of these solutions worked for you depending on which OS you have, I wish you good luck with your Python Journey.

For donations you can use the red Kofi button above, keep learning and keep coding, cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/