python-3.x - 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 已崩溃。
当我尝试使用 (sudo google-chrome) 运行 google-chrome 时,我收到以下消息: [56:56:0316/235226.650275:ERROR:zygote_host_impl_linux.cc(89)] 不支持在没有 --no-sandbox 的情况下以 root 身份运行. 请参阅https://crbug.com/638180。
我尝试修改 /usr/bin 中的 google-chrome 文件,但它是只读的,所以我在网上找到的解决方法是在上面的代码中添加选项“--no-sandbox”。但一直没有解决问题。
解决方案
解决方案:
此错误“AttributeError: 'LifoQueue' object has no attribute 'put' selenium webdriver”是由于您的工作目录中有一个名为 Queue. 重命名那个。
对于此错误“从 chrome 位置 /usr/bin/google-chrome 开始的进程不再运行,因此 ChromeDriver 假定 Chrome 已崩溃。”
如果您尝试了所有可能的解决方案但仍然遇到问题,那么如果您使用似乎导致问题的 Linux 虚拟机,我建议在 Windows 上安装 docker 桌面并下载包含运行 selenium 所需的所有库的 docker 映像应用 。
推荐阅读
- python-3.x - 如何使用 Tensorflow from_generator 将多个序列和标签的生成器转换为数据集?
- matlab - MATLAB 中用于距离-方位角映射的 2D-MUSIC 算法
- javascript - 通过 _id 查找总是比通过不同的唯一字段查找更快吗?(mongodb)
- java - 将 REST 响应映射到 Mono 的正确方法
使用 WebClient/Spring Boot 2 - java - @InjectMocks 没有正确注入依赖项
- r - 将 ConditionalPanel 与 checkboxGroupInput 一起使用
- layout - Ngx 管理模板侧边栏和内容布局
- javascript - 验证数组 Json Javascript
- flutter - 如何在 Flutter 的输入文本字段中动态渲染 TeX 方程?
- git - Git 将文件从一个存储库移动到另一个存储库以获取历史记录