Skip to content
← Back to Community
Adding PATH variables.
Profile icon
12944qwerty

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 [earned 5 cycles]
View Answer
Voters
Profile icon
hussnainML
Profile icon
RipFive
Profile icon
12944qwerty
Comments
hotnewtop
Profile icon
Scoder12

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.

Profile icon
12944qwerty

@Scoder12 Thank you! This worked!

Profile icon
Lavender3

@Scoder12 this is working.
To those who are still struggling, download the correct version of chromedriver on the official website. Must be same as your chromium-browser version on Ubuntu.
Code works

Profile icon
finnegan

You have beaten yourself this time, and I appreciate you and hopping for some more informative posts in future. Thank you for sharing great information to us.Ethereum NFT

Profile icon
bapexa

Some other benefits of our matchmaking site include daily & weekly match alerts, enhanced search and single-page registration. Have special marriage / matrimony ... https://www.matchfinder.in

Profile icon
Kognise

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.

Profile icon
12944qwerty

@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.)
Profile icon
12944qwerty

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