Ask coding questions

← Back to all posts
Adding PATH variables.
12944qwerty (5)

I'm trying to connect a chromedriver to python but I need to add it to PATH. Is there any way I could do this?

Answered by Scoder12 (839) [earned 5 cycles]
View Answer
Comments
hotnewtop
Scoder12 (839)

You can't use .exe files on repl.it because repl.it uses linux (technically you can but its a lot easier to just use the linux version). You can use this code instead of your driver line:

import os
import stat
from selenium.webdriver.chrome.options import Options


st = os.stat('chromedriver')
os.chmod('chromedriver', st.st_mode | stat.S_IEXEC)
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome('./chromedriver', options=chrome_options)

You also have the wrong chromedriver binary. If you open a shell with ctrl+shift+s in the repl, you can see

$ chromium-browser --version
Chromium 81.0.4044.138 Built on Ubuntu , running on Ubuntu 18.04

And your chromedriver binary only supports version 83:

$ chmod +x ./chromedriver && ./chromedriver
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/[email protected]{#416}) on port 9515

You can download the correct binary from here or from my repl.

Please mark this as the answer if it helped you.

Kognise (437)

Hey! It looks like the error message is being confusing, the actual issue is that the path to chromedriver that you specified (./chromedriver.exe) doesn't exist. If you look, the actual file doesn't have the .exe extension, so you need to remove that. Repl.it runs linux and not windows so executables have a different format and no extension by convention.

Also, chromedriver has to be marked as an executable. Do ctrl-shift-p and type "Open Shell" and then run chmod +x ./chromedriver and everything should work! Pretty sure you still have some other errors.

12944qwerty (5)

@Kognise I tried running chmod +x ./chromedriver. Nothing got printed into the shell but when I ran the file again, the error saying that

(The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
12944qwerty (5)

@Kognise It may have been because I had the wrong chromedriver version?