0

I've been working on a project for a while now. Only recently, for whatever reason I started getting an error:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

This is strange because I already have chromedriver in PATH. I've also had chromedriver in the same folder as the project I've been working on. I've also gone to the extent to create a test file named moo.py. It's very basic with the intent of testing the chromedriver. The code is as follows:

from selenium.webdriver.chrome.options import Options
from time import sleep
from selenium import webdriver

options = Options()
options.binary_location = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
driver = webdriver.Chrome(executable_path=r'C:\webdrivers\chromedriver.exe', chrome_options = options)
driver.get('https://www.google.com')
print('Chrome opened')
time.sleep(5)
driver.quit()

Even when running this, it still gives me the same error. I'm not really sure what to do now since I've tried fixing this the several various ways I know how. I'd appreciate any and all feedback. Kind regards.

edit 1: Chromedriver is actively working in PATH.

C:>chromedriver Starting ChromeDriver 92.0.4515.107 (87a818b10553a07434ea9e2b6dccf3cbe7895134-refs/branch-heads/4515@{#1634}) 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.

That's the response when I type chromedriver into cmd with C:\ as the cd.

Some additional information, I'm on Windows 10, laptop. Chromedriver was working fine before, then just seemingly stopped out of nowhere.

from selenium.webdriver.chrome.options import Options
from time import sleep
from selenium import webdriver

# options = Options()
# options.binary_location = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
# driver = webdriver.Chrome(executable_path=r'C:\webdrivers\chromedriver.exe', chrome_options = options)
driver = webdriver.Chrome()
driver.get('https://www.google.com')
print('Chrome opened')
time.sleep(5)
driver.quit()

I then tried to comment out the part about finding chrome, made sure I had the right version of chromedriver in the same folder as moo.py, changed the code to the above, and still get the same error.

After that, I removed the chromedriver from the folder with moo.py, insinuating that it would just get the info from PATH, and it again, throws the same error.

And here is the entire traceback error I get. Same error every time.

C:\webdrivers>python moo.py Traceback (most recent call last): File "C:\Users\Sean\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Users\Sean\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 829, in init errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "C:\Users\Sean\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1279, in _get_handles c2pwrite = msvcrt.get_osfhandle(self._get_devnull()) File "C:\Users\Sean\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1062, in _get_devnull self._devnull = os.open(os.devnull, os.O_RDWR) FileNotFoundError: [Errno 2] No such file or directory: 'nul'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\webdrivers\moo.py", line 22, in driver = webdriver.Chrome() File "C:\Users\Sean\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in init self.service.start() File "C:\Users\Sean\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

ArimusAOV
  • 1
  • 4
  • 2
    Does this answer your question? [Error message: "'chromedriver' executable needs to be available in the path"](https://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path) – It_is_Chris Aug 10 '21 at 19:20
  • I've tried many of the things suggested in that thread, all while still getting the same error. It's quite befuddling. I'm on windows 10, so the Linux/ubuntu stuff doesn't apply for me from that thread. – ArimusAOV Aug 10 '21 at 19:42
  • Are you using a virtualenv? – dir Aug 10 '21 at 20:52
  • No, not using a virtual environment. That's probably well above my skill level. – ArimusAOV Aug 10 '21 at 20:55

1 Answers1

0

Add to the system PATH where the ChromeDriver binary is.

Restart you python interpreter or jupyter. Don't need to set options.

Also make sure you have the correct version for you current Chrome (that's updated automatically).

And it's going to work.

I've being using selenium python for quite some time this way (windows 10).

imbr
  • 6,226
  • 4
  • 53
  • 65
  • I have the binary for ChromeDriver in PATH. I've also tried having ChromeDriver in the same folder as the file I'm working with, and I've also tried linking ChromeDriver in the file. I still get the same error. I've even restarted my PC to see if that would change anything, and still, the same error persists. – ArimusAOV Aug 10 '21 at 22:20
  • well I got similar error in the past and causes were: or incorrect version, or mixing things w. options, wrong setting the PATH or not a restart-clean python interpreter. – imbr Aug 11 '21 at 11:32