0

I have tried many of the solutions given on stackoverflow but none of them have worked.

I want to open google chrome in selenium using python using an ubuntu shell on windows, however whenever I do I get an error. Terminal where I run the code as well as the folder path

I have tried to do this by specifying the path in the webdriver.Chrome function like so,

webdriver.Chrome('/path/to/chromedriver.exe') 

but the same error keeps happening,

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/vinve/Desktop/chromedriver_win32/chromedriver.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

I have tried typing the path using double slashes and as a raw string but nothing works.

I also added to chromedriver.exe file to the scripts folder but that didn't help. I also ran the path like so webdriver.Chrome(/path/to/chromedriver) without the .exe and that didnt work. I also tried running it with chrome_options in the --headless mode but that didnt work. (all these options gave the same error above)

EDIT: ANSWER: I figured it out! it was the fact that although I was on windows 10, I was using Windows Subsystem for Linux (Ubuntu shell). So the path that is specified in the webdriver.Chrome(/path/to/chromedriver.exe) should not begin with C:/path/to/driver.exe rather is should be /mnt/c/Users/path/to/chromedriver.exe

vivekh99
  • 31
  • 7
  • Make sure the chrome driver with `.exe` or not in your location. If without `.exe` try : `webdriver.Chrome('/path/to/chromedriver')` – frianH Aug 17 '19 at 22:27
  • Hi I did this without the .exe but got the same error again about there being no such file or directory (in the folder there is no .exe for chromedriver so i implemented it without the .exe). Do you have any ideas why? Im pretty sure that the path is correct (shown in the pic of the original post). – vivekh99 Aug 18 '19 at 19:56

1 Answers1

0

It should be webdriver.Chrome('/path/to/chromedriver') without the .exe

FishMonkey
  • 178
  • 4
  • 15
  • Hi I did this without the .exe but got the same error again about there being no such file or directory. Do you have any ideas why? Im pretty sure that the path is correct (shown in the pic of the original post). – vivekh99 Aug 18 '19 at 19:55
  • Hmmm did you try adding it to the PATH like the error shows? – FishMonkey Aug 22 '19 at 05:16
  • Actually I figured it out! it was the fact that although I was on windows 10, I was using Windows Subsystem for Linux (Ubuntu shell). So the path that is specified in the webdriver.Chrome(/path/to/chromedriver.exe) should not begin with C:/path/to/driver.exe rather is should be /mnt/c/Users/path/to/chromedriver.exe...Thank you for your help! – vivekh99 Aug 22 '19 at 14:21