解决python出现的Executable executable_path has been deprecated问题

这篇具有很好参考价值的文章主要介绍了解决python出现的Executable executable_path has been deprecated问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1、错误脚本:

# 导入selenium
import time

from selenium import webdriver

# 选择谷歌浏览器
driver = webdriver.Chrome(executable_path=r'C:\Program Files\python39\chromedriver.exe')
# 输入网址
driver.get("https://www.baidu.com/")
# 操作网址
time.sleep(3)
# 打印网页title
print(driver.title)
# 关闭网址
driver.quit()

错误结果:

executable_path,chrome,python,前端

2、错误原因

出现 DeprecationWarning 警告的类型错误:

该类型的警告大多属于版本更新时,所使用的方法过时的原因;某方法在当前版本被重构,依旧可以传入参数,但是在之后的某个版本会被删除。

3、解决方案

# 导入selenium
import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

# 选择谷歌浏览器
s = Service(executable_path=r'C:\Program Files\python39\chromedriver.exe')
driver = webdriver.Chrome(service=s)
# 输入网址
driver.get("https://www.baidu.com/")
# 操作网址
time.sleep(3)
# 打印网页title
print(driver.title)
# 关闭网址
driver.quit()

 正确结果:

executable_path,chrome,python,前端

 文章来源地址https://www.toymoban.com/news/detail-596940.html

到了这里,关于解决python出现的Executable executable_path has been deprecated问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver =

    解决warning: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Edge(\\\'C:/Users/cong/AppData/Local/Programs/Python/Python310/msedgedriver.exe\\\',options=option) 这个警告信息是在使用Python的Selenium库时出现的。它提示说“executable_path”已经被弃用了,建议使用一个Serv

    2024年02月11日
    浏览(6)
  • 【Error】DeprecationWarning: executable_path has been deprecated, please pass in a Service object

    解决warning: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Edge(\\\'C:/Users/cong/AppData/Local/Programs/Python/Python310/msedgedriver.exe\\\',options=option) 这个警告信息是在使用Python的Selenium库时出现的。它提示说“executable_path”已经被弃用了,建议使用一个Serv

    2024年02月06日
    浏览(8)
  • selenium 报错 DeprecationWarning: executable_path has been deprecated, please pass in a Service object

    selenium 报错 DeprecationWarning: executable_path has been deprecated, please pass in a Service object

    出现 DeprecationWarning 警告的类型错误:该类型的警告大多属于版本已经更新,所使用的方法过时。 查询当前版本重构后的函数,是之前的 executable_path 被重构到了 Service 函数里 尝试解决方法:

    2024年02月16日
    浏览(7)
  • 测试-selenium学习|报错 :DeprecationWarning: executable_path has been deprecated, please pass in a Servic

    在使用selenium的时候运行如下代码的时候报出错误 :DeprecationWarning: executable_path has been deprecated, please pass in a Service object 查询得知: “出现 DeprecationWarning 警告的类型错误:该类型的警告大多属于版本已经更新,所使用的方法过时。 当前版本重构后的函数,是之前的 executab

    2023年04月14日
    浏览(7)
  • 使用npm install出现check python checking for Python executable “python2“ in the PATH

    使用npm install出现check python checking for Python executable “python2“ in the PATH

    使用npm install出现check python checking for Python executable \\\"python2\\\" in the PATH时,表示你本地的环境需要使用python2.7的,这个时候可以使用  npm install --global windows-build-tools  进行下载, !!!记住因为环境是在c盘下的,使用得用管理员的cmd, 但是在执行的时候会卡住, 在下面这段代

    2024年02月09日
    浏览(11)
  • 使用pycharm配置出现Conda executable path is empty问题

    使用pycharm配置出现Conda executable path is empty问题

    Conda executable path is empty 在pycharm中配置使用Conda Environment出现Conda executable path is empty报错 报错为conda可执行路径为空,可能原因有三,可以一次排除 是否安装并能使用anaconda Conda executable的位置错误 Interpreter(python翻译器)位置错误 如果是原因一,则先安装配置好anaconda 原因二

    2024年02月13日
    浏览(11)
  • XCode 14.2 运行MonkeyDev项目出现Executable Path is a Directory

    XCode 14.2 运行MonkeyDev项目出现Executable Path is a Directory

    解决办法: 更改Generate info.plist file 的值为NO, 将info.plist File 的值改为xxx/info.plist  问题: The WatchKit app\\\'s Info.plist must have a XXX  解决办法:1. 删除weChat.app/com.apple.WatchPlaceholder 文件夹                    2. 删除DerivedData缓存                     3. 工程clean一下

    2024年02月13日
    浏览(10)
  • selenium的Edge驱动安装后,仍出现‘MicrosoftWebDriver.exe‘ executable needs to be in PATH.

    selenium的Edge驱动安装后,仍出现‘MicrosoftWebDriver.exe‘ executable needs to be in PATH.

    首先已经在edge的网站 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 中下载了符合浏览器版本的edge驱动器 我们可以看到解压后的驱动器的文件名为msedgedriver.exe 运行该程序后出现一下错误 (1)直接修改驱动器名称 由于驱动器本身是官网下载,而为Microsoft Edge WebDrive

    2024年02月13日
    浏览(7)
  • Xcode运行程序提示 Executable Path is a Directory 问题解决

    Xcode运行程序提示 Executable Path is a Directory 问题解决

    一次iOS的开发中,利用Object-C工程编写的程序,点击运行到真机调试到时候,编译是成功了,但是却弹出一个窗口: 提示“Executable Path is a Directory”,貌似说可执行文件是个文件夹。无法进行运行和调试。 在网上找了半天也没找到最终解决方法。最后发现在项目设置中,TA

    2024年02月12日
    浏览(30)
  • PyCharm添加Anaconda中的虚拟环境,Python解释器出现Conda executable is not found(解决方案)

    PyCharm添加Anaconda中的虚拟环境,Python解释器出现Conda executable is not found(解决方案)

    项目场景: 在使用Anconda配置好虚拟环境后,需要添加到PyCharm中遇到的问题。 作者是在创建新项目的时候,选择conda环境出现Conda executable is not found的错误, 本机Window10系统安装PySpark环境。 作者猜测原因:本机中没有配置全局Anconda环境,识别不出conda.exe文件(本机Anconda安装

    2024年02月05日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包