Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL cannot open chromedriver.exe in /mnt/c #4932

Closed
YiRuChenbilibili opened this issue Feb 26, 2020 · 4 comments
Closed

WSL cannot open chromedriver.exe in /mnt/c #4932

YiRuChenbilibili opened this issue Feb 26, 2020 · 4 comments

Comments

@YiRuChenbilibili
Copy link

I just updated my wsl to wsl2. In wsl I can easily use my chromedriver by set (chrome_driver = "/mnt/c/Program Files (x86)/Google/Chrome/Application/chromedriver.exe")then driver = webdriver.Chrome(chrome_driver)
But after I started to use WSL2.It raises the problems like this:
Traceback (most recent call last):
File "", line 1, in
File "/home/chen/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in init
self.service.start()
File "/home/chen/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 104, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /mnt/c/Program Files (x86)/Google/Chrome/Application/chromedriver.exe
what should I do?Or it's just not support?

@therealkenc
Copy link
Collaborator

There is no repro here, but if your scenario was working in WSL1 and not WSL2 that usually is because of loss of localhost transparency in WSL2. Since chromedriver.exe is presumably listening on the Windows side, this is very probably dupe #4199. It is almost certainly possible to get your scenario working using the real IP address of the service (think: chromeserver.exe on another machine). There is not nearly enough to go on here to tell you how to go about that (or even speculate); though a forum familiar with python and selenium might.

@dfanica
Copy link

dfanica commented May 18, 2020

@YiRuChenbilibili I want to use chomedriver.exe from WSL (I have version 1) but I keep getting org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.

Initially I thought that you can't call chromedriver.exe (since it's listening on Windows side) from WSL (which is on Ubuntu 18.04 side) but then I saw you post here and I was wondering if this is possible and I'm missing something?

I have Chrome Version 80.0.3987.149 (Official Build) (64-bit), on Windows 10, and I'm using ChromeDriver 80.0.3987.106 and I'm calling it via WSL with webdriver.chrome.driver = /mnt/c/chromedriver.exe

Since I can't get this to work I'm looking now to set this up running Maven from Windows rather than WSL. Any help appreciated. Thanks.

@YiRuChenbilibili
Copy link
Author

I simply try this in WSL(version 1):
from selenium import webdriver

driver = webdriver.Chrome(executable_path="/mnt/c/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/Scripts/chromedriver.exe")

driver.get("http://www.baidu.com")

print(driver.page_source)

driver.quit()

And it can work.

@mangelozzi
Copy link

There is no repro here, but if your scenario was working in WSL1 and not WSL2 that usually is because of loss of localhost transparency in WSL2. Since chromedriver.exe is presumably listening on the Windows side, this is very probably dupe #4199. It is almost certainly possible to get your scenario working using the real IP address of the service (think: chromeserver.exe on another machine). There is not nearly enough to go on here to tell you how to go about that (or even speculate); though a forum familiar with python and selenium might.

The only issue with this, is that chromedriver only allows one to connect to local host for security reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants