Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Chrome在一段时间后关闭并产生错误selenium.common.exceptions.WebDriverException:Message:无法连接到python中的服务_Python_Google Chrome_Selenium - Fatal编程技术网

Chrome在一段时间后关闭并产生错误selenium.common.exceptions.WebDriverException:Message:无法连接到python中的服务

Chrome在一段时间后关闭并产生错误selenium.common.exceptions.WebDriverException:Message:无法连接到python中的服务,python,google-chrome,selenium,Python,Google Chrome,Selenium,在python中执行上述代码时,chrome浏览器打开,但未重定向到。2或3秒后,chrome将自动关闭并产生错误: 回溯(最近一次调用last):文件“test.py”,第4行,在 driver=webdriver.Chrome(可执行文件路径=“/snap/bin/Chrome”)文件 “/home/ShihaD/.local/lib/python2.7/site packages/selenium/webdriver/chrome/webdriver.py”, 第68行,在init sel

在python中执行上述代码时,chrome浏览器打开,但未重定向到。2或3秒后,chrome将自动关闭并产生错误:

回溯(最近一次调用last):文件“test.py”,第4行,在 driver=webdriver.Chrome(可执行文件路径=“/snap/bin/Chrome”)文件 “/home/ShihaD/.local/lib/python2.7/site packages/selenium/webdriver/chrome/webdriver.py”, 第68行,在init self.service.start()文件“/home/ShihaD/.local/lib/python2.7/site packages/selenium/webdriver/common/service.py”, 第104行,开始 引发WebDriverException(“无法连接到服务%s”%self.path)selenium.common.exceptions.WebDriverException:消息:Can 未连接到服务/快照/存储箱/服务器

我已经试过了。但不起作用

版本: Python 2.7.15 谷歌浏览器67.0.3396.99 铬驱动2.40


选中的/etc/hosts和127.0.0.1 localhost已写入其中。

“/usr/bin/google chrome”
是指向
谷歌chrome
网络浏览器的路径,而不是指向Yep,已解决。谢谢
from selenium import webdriver
driver = webdriver.Chrome(executable_path="/usr/bin/google-chrome")
driver.get('https://python.org')