1

This is the error I keep getting. I have searched google multiple times trying to figure this issue out. I have added msedgedriver.exe to the PATH several times in a few different locations on my pc. I followed this: How to open up Microsoft Edge using Selenium and Python

This is what I am trying to run.

from selenium import webdriver

driver = webdriver.Edge(executable_path=r'C:\path\to\msedgedriver.exe')
driver.get('edge://settings/help')
print("Page title is: %s" %(driver.title))
#driver.quit()

this is the error:

 from selenium import webdriver
>>>
>>> driver = webdriver.Edge(executable_path=r'C:\path\to\msedgedriver.exe')
Traceback (most recent call last):
  File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 56, in __init__
    self.edge_service.start()
  File "C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'msedgedriver.exe' executable needs to be in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687

Please someone help. lol this is driving me nuts. Thank you :)

Removing r from

driver =webdriver.Edge(executable_path=r'C:\path\to\msedgedriver.exe')
5
  • Try moving msedgedriver.exe file to C:\Program Files (x86) Commented Nov 27, 2021 at 20:07
  • Or try to just remove the r that is in your executeble_path Commented Nov 27, 2021 at 20:10
  • I tried that and I got a access is denied error: PermissionError: [WinError 5] Access is denied Commented Nov 27, 2021 at 20:29
  • removing r worked!! Can you explain, please? Commented Nov 27, 2021 at 20:31
  • Usually you use r to indicate that you want to read the file, but in this case that will not work for a webdriver Commented Nov 28, 2021 at 11:03

1 Answer 1

1

Downloading the webdriver manually has always led to problems... unless of course you are very careful in your methods. Here's an alternative... use the webdriver_manager library (https://pypi.org/project/webdriver-manager/) to download and handle the driver by itself.

from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from webdriver_manager.chrome import ChromeDriverManager

edge = webdriver.Edge(EdgeChromiumDriverManager().install())
chrome = webdriver.Chrome(ChromeDriverManager().install())

I would also recommend you to use the chromedriver rather than the edgedriver since chrome is more robust and well tuned for such applications.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm confused on how to run this. I have installed the manager via pip. I run into this error when I try to run the above: >>> from selenium import webdriver >>> from webdriver_manager.microsoft import EdgeChromiumDriverManager >>> from webdriver_manager import ChromeDriverManager Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'ChromeDriverManager' from 'webdriver_manager' (C:\Users\tut3p\AppData\Local\Programs\Python\Python310\lib\site-packages\webdriver_manager_init_.py) @PreciXon
Sorry about that, there's a small error in the input statement for ChromeDriverManager. Fixed it now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.