最佳答案
最近我换了台电脑,从那以后我就不能用硒来启动 chrome 了。我也试过 Firefox,但是浏览器实例就是启动不了。
from selenium import webdriver
d = webdriver.Chrome('/home/PycharmProjects/chromedriver')
d.get('https://www.google.nl/')
我得到以下错误:
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 /opt/google/chrome/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.43.600233, platform=Linux 4.15.0-38-generic x86_64)
我有最新的铬版本和铬驱动程序安装
编辑: 在尝试@b0sss 解决方案后,我得到了以下错误。
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(chrome not reachable)
(The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so chromedriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d),platform=Linux 4.15.0-38-generic x86_64)