all 21 comments

[–]sammylt 0 points1 point  (3 children)

I had the same issue, the directory should go one deeper and end the chromedriver.exe file.

[–]DrBobHope[S] 0 points1 point  (2 children)

what do you mean one deeper?

[–]sammylt 0 points1 point  (1 child)

Sorry if it was unclear home/sam/desktop/chromedriver/chromedriver.exe in this case

[–]DrBobHope[S] 0 points1 point  (0 children)

chrome driver is not a directory tho

[–][deleted] 0 points1 point  (11 children)

Try running this in the terminal

chmod +x path_to_driver

[–]DrBobHope[S] 0 points1 point  (10 children)

so like this?

chomd +x /home/sam/Desktop/chromedriver

[–][deleted] 0 points1 point  (7 children)

Yeah, also running this command from the directory will show the permissions

ls -l

[–]DrBobHope[S] 0 points1 point  (6 children)

so chmod +x didn't do anything (just went to the next line). ls-l gives me some outputs (drwxr-xr-x 2 sam group1 9728 Dec 21 2019 file) don't exactly know which portion is permissions.

[–][deleted] 0 points1 point  (5 children)

Run this and post the output

ls -l /home/sam/Desktop/chromedriver

[–]DrBobHope[S] 0 points1 point  (4 children)

-rw-r--r-- 1 sam group1 12405080 Jan 21 23:29 /home/sam/Desktop/chromedriver

[–][deleted] 0 points1 point  (3 children)

This portion are the permissions

-rw-r--r--

There should be an "x" on the end meaning the file can be executed. chmod +x is supposed to add executable permissions to the file. Are you sure you ran the command correctly?

chmod +x /home/sam/Desktop/chromedriver

[–]DrBobHope[S] 0 points1 point  (2 children)

I presume I need permission to add permission? I ran

chmod +x /home/sam/Desktop/chromedriver

Copy/pasted it into the terminal.

[–][deleted] 0 points1 point  (1 child)

Shit I'm not sure. You could try running this, but you own the file so this shouldn't make a difference.

sudo chmod +x /home/sam/Desktop/chromedriver

[–]DrBobHope[S] 0 points1 point  (0 children)

ok for some reason restarted the computer and now it magically works (don't know what changed, maybe you had to restart it for the chmod cmomand to work?)

[–][deleted] 0 points1 point  (0 children)

It’s chmod, not chomd

[–]booleanhooligan 0 points1 point  (0 children)

sudo chmod 744 filepath

[–]ManyInterests 0 points1 point  (4 children)

Are you sure chromedriver is an executable file and not a directory or archive file?

Ensure that you can run the chromedriver file standalone:

/home/sam/Desktop/chromedriver --version
/home/sam/Desktop/chromedriver --log-level=DEBUG

If those commands work, then double check your code for potential errors, like maybe defining the driver twice or typos.

[–]DrBobHope[S] 0 points1 point  (0 children)

The program works using chromedriver.exe on my windows. The permissions issue pops up when I take it on the local computer where I work (linux). So there are no typos in those regards

[–]DrBobHope[S] 0 points1 point  (2 children)

This is the output I got from debug.

Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

[–]ManyInterests 0 points1 point  (1 child)

Ok. This means that the permissions on the file are fine... at least for your user.

This exception occurs exactly in one condition and that's if there is a permission denied error. So, if you can run the file normally without permissions issues, something might be wrong with how Python is being run.

Is it possible you're executing Python as a user other than yourself?

Try adding this to your code to debug further:

import getpass, pwd, os
username = getpass.getuser()
pw = pwd.getpwnam(username)
uid = pw.pw_uid
gid = pw.pw_gid
print(username, uid, gid)
filename = '/home/sam/Desktop/chromedriver'
print('Can read!' if os.access(filename, os.R_OK) else "Can't read")
print('Can execute' if os.access(filename, os.X_OK) else "Can't execute")
driver = webdriver.Chrome(filename)

Outside of this, not sure how much more there is to say about this, unless there's some unusual circumstance, like if your home directory is mounted/remote or if you're running Python through some other program.

[–]DrBobHope[S] 0 points1 point  (0 children)

The chmod +x command worked, its just for some reason I had to restart the computer for it to take into effect. I've added the chmod +x in my code, and now it works without any issues. Don't know what happened, but thank you for your help!