首页 > 解决方案 > AttributeError: 'LifoQueue' 对象没有属性 'put' selenium webdriver

问题描述

我已经安装了 selenium 和 chrome web 驱动程序,并可以通过我的操作系统的路径变量访问它(在 windows 和 python3 上使用 Linux 虚拟机)。我运行这个简单的代码并得到以下错误。关于可能导致此错误的任何想法?

提前致谢!

安装的 Selenium 版本: selenium-3.141.0 urllib3-1.25.8

已安装 Chrome 驱动程序(Chrome 浏览器 80 的最新版本): ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987@{#882})

已安装 Chrome 浏览器: Google Chrome 80.0.3987.132

Python版本: Python 3.6.9

import selenium
from selenium import webdriver

options = webdriver.chrome.options.Options()

options.add_argument('--no-sandbox') 
options.add_argument('--disable-dev-shm-usage')

chromedriver = '/usr/bin/chromedriver'

print('test0') #is being printed

driver = webdriver.Chrome('/usr/bin/chromedriver',options=options)

print('test') #not being printed

driver.get('http:google.com')

运行代码时出现错误消息:从 chrome 位置 /usr/bin/google-chrome 开始的进程不再运行,因此 ChromeDriver 假设 Chrome 已崩溃。

错误信息 2

当我尝试使用 (sudo google-chrome) 运行 google-chrome 时,我收到以下消息: [56:56:0316/235226.650275:ERROR:zygote_host_impl_linux.cc(89)] 不支持在没有 --no-sandbox 的情况下以 root 身份运行. 请参阅https://crbug.com/638180

错误信息 3

我尝试修改 /usr/bin 中的 google-chrome 文件,但它是只读的,所以我在网上找到的解决方法是在上面的代码中添加选项“--no-sandbox”。但一直没有解决问题。

已解决:工作目录中有一个名为 queue 的 python 文件,必须重命名它 错误信息

标签: python-3.xseleniumselenium-chromedriver

解决方案


解决方案:

此错误“AttributeError: 'LifoQueue' object has no attribute 'put' selenium webdriver”是由于您的工作目录中有一个名为 Queue. 重命名那个。

对于此错误“从 chrome 位置 /usr/bin/google-chrome 开始的进程不再运行,因此 ChromeDriver 假定 Chrome 已崩溃。”

如果您尝试了所有可能的解决方案但仍然遇到问题,那么如果您使用似乎导致问题的 Linux 虚拟机,我建议在 Windows 上安装 docker 桌面并下载包含运行 selenium 所需的所有库的 docker 映像应用 。


推荐阅读