Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.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
Python Selenium ChromeDriver抛出Chrome启动失败错误_Python_Selenium - Fatal编程技术网

Python Selenium ChromeDriver抛出Chrome启动失败错误

Python Selenium ChromeDriver抛出Chrome启动失败错误,python,selenium,Python,Selenium,上述代码无法成功运行chromedriver,其错误消息为: from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.binary_location = driver_path options.add_argument("--start-maximized") options.add_argument(&q

上述代码无法成功运行chromedriver,其错误消息为:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = driver_path
options.add_argument("--start-maximized")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")

driver = webdriver.Chrome(options=options, executable_path=driver_path)
我看到了一些将包含驱动程序文件的文件夹设置为path的建议,但我不希望使用该方法,因此我没有尝试过


我不知道司机为什么死了。驱动程序是最新的,版本与安装的Chrome浏览器相匹配。这台计算机有24GB的额外RAM,所以不太可能是RAM问题。奇怪的是,这些代码在我的笔记本电脑中有效,但在我的桌面上却不起作用。

删除引号后,你能确认一下吗 考虑到您已经声明了
driver\u路径

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: was killed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location ${driver_path} is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

听起来像是目录问题。尝试将driver_path设置为字符串,在其中复制web驱动程序exe的路径。例如:r“C:\Users\Person\chromeWebDriver.exe”


用户r“”以确保它忽略后斜杠。试着看看你是否可以用直接路径启动它,看看这是否是一个dir问题。

我刚刚得到了解决方案。许多解决方案建议
选项的值。二进制位置
应该是ChromeDriver路径,但必须是Chrome浏览器二进制路径。所以这一切都成功了:

options=options()
options.binary\u location=chrome\u路径
options.add_参数(“--start maximized”)
options.add_参数(“--no sandbox”)
options.add_参数(“--disable dev shm usage”)
driver=webdriver.Chrome(选项=选项,可执行路径=驱动路径)

这只是打字错误。我正确地声明了驱动程序路径。对不起,我用的是原始字符串。错误消息并没有说它找不到驱动程序;它说驱动程序已被杀死。请尝试“chrome\u选项-options()”然后尝试“chrome\u选项”。使用chrome\u选项(“detach”=True)”
driver = webdriver.Chrome(options=options, executable_path=driver_path)