在Windows的Linux子系统上无法从Selenium启动Chrome
这是我的第一次发贴,因此,如果我遗漏任何明显的内容,我谨向您致歉.我正在尝试在Windows的Linux子系统上的Ubuntu(18.04.3 LTS)版本上通过python3通过Selenium启动Chrome.我在/usr/bin/chromedriver
中安装了chromedriver,并通过pip3 install chromedriver-binary
安装了二进制文件.这些命令是:
This is my first time posting, so I apologize in advance if I'm missing anything glaringly obvious. I'm attempting to launch Chrome via Selenium through python3 on a version of Ubuntu (18.04.3 LTS) on a Linux subsystem for Windows. I have chromedriver installed in /usr/bin/chromedriver
, and installed the binary through pip3 install chromedriver-binary
. The commands are:
from selenium import webdriver
driver = webdriver.Chrome()
当我尝试执行第二行时,出现错误
When I try to execute the second line, I get the error
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.).
我一直在闲逛,听起来好像我可能需要传递到Chrome()的路径,但是我什至不确定这是否是问题所在.我肯定会和他们一样环保,所以在此先感谢您的帮助!
I've poked around, and it sounds like I might need to pass in the path to Chrome(), but I'm not even sure if that is the issue or not. I'm definitely about as green as they come, so thanks in advance for any help!
听起来好像您没有通过远程调试端口启动Chrome.
Sounds like you haven't started Chrome with a remote debugging port.
找到chrome的路径并使用该标志-remote-debugging-port=9222
Find path to chrome and run with this flag -remote-debugging-port=9222
https://developer.mozilla.org/zh-CN /docs/Tools/Remote_Debugging/Chrome_Desktop