首页 > Python资料 博客日记
python selenuim TypeError: WebDriver.__init__() got an unexpected keyword argument ‘chrome_options‘
2024-03-16 02:00:04Python资料围观428次
本篇文章分享python selenuim TypeError: WebDriver.__init__() got an unexpected keyword argument ‘chrome_options‘,对你有帮助的话记得收藏一下,看Python资料网收获更多编程知识
Python selenuim TypeError: WebDriver.__init__() got an unexpected keyword argument 'chrome_options'
运行客户端:Pycharm
运行程序如下:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
wd = webdriver.Chrome(chrome_options=options, executable_path=r'c:\chromedriver\chromedriver.exe')
Run之后出现的错误如下。
TypeError: WebDriver.__init__() got an unexpected keyword argument 'chrome_options'/'executable_path'
在Anaconda里面是可以运行成功的,所以由此我们查询了其selenium版本。
而此时在Pycharm中,selenium的版本是 4.15.2的新版本,包括urllib3的版本。
解决方案:
一、统一变成低版本 可直接运行代码的版本。
参阅:Selenium |AttributeError: 'WebDriver' object has no attribute 'find_element_by_class_name' - 老表爱技术https://www.cnblogs.com/rychh/p/17146472.html
二、维持Pycharm中版本不变,改代码去适应新版本的需求。
import time,os,re
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
service = Service(executable_path=r'c:\chromedriver\chromedriver.exe)
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
#......
driver.quit()
可参阅:
https://stackoverflow.com/questions/76550506/typeerror-webdriver-init-got-an-unexpected-keyword-argument-executable-p
萌新公众号 欢迎关注。
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
标签:
相关文章
最新发布
- Python pycryptodome类库使用学习总结
- import torch 报错:WinError 126
- 如何在Java中实现邮件发送功能?
- python之openpyxl模块——实现Excel表格的处理(万字教学,全网最全,超详细!)
- BUG解决:postman可以请求成功,但Python requests请求报403
- 解决Pycharm下载torch报错:OSError: [WinError 126] 找不到指定的模块。
- python创建线程和结束线程
- 精通Python(基础篇)pip命令大全(非常详细)零基础入门到精通,收藏这一篇就够了
- Python中的列表(list)
- ImportError: /usr/local/lib/python3.8/dist-packages/flash_attn_2_cuda.cpython-38-x86_64-linux-gnu.so
点击排行
- 版本匹配指南:Numpy版本和Python版本的对应关系
- Python 可视化 web 神器:streamlit、Gradio、dash、nicegui;低代码 Python Web 框架:PyWebIO
- 版本匹配指南:PyTorch版本、torchvision 版本和Python版本的对应关系
- 相关性分析——Pearson相关系数+热力图(附data和Python完整代码)
- Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based proj
- Python pyinstaller打包exe最完整教程
- Anaconda版本和Python版本对应关系(持续更新...)
- Python与PyTorch的版本对应