You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用undetected-chromedriver时出现TypeError的解决方法

解决undetected-chromedriver的TypeError问题

这个错误的核心原因是undetected-chromedriver未能自动找到Chrome浏览器的可执行文件路径,导致传入了None值引发类型错误。以下是几种可行的解决方法:

  • 手动指定Chrome可执行文件路径
    直接在代码中指定Chrome的安装路径,避免自动检测失败。示例代码:

    import undetected_chromedriver as uc
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    # 替换为你本地Chrome的实际安装路径,Windows下常见路径如下,Mac/Linux需调整
    options.binary_location = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
    driver = uc.Chrome(options=options)
    driver.get('https://nowsecure.nl')
    
  • 更新undetected-chromedriver到最新版本
    旧版本可能存在路径检测逻辑的bug,执行以下命令升级:

    pip install --upgrade undetected-chromedriver
    
  • 验证Chrome安装状态
    确认Chrome已正常安装且能启动,若为自定义安装或绿色版,务必保证binary_location指向的路径准确无误。

  • (可选)配置系统环境变量
    将Chrome可执行文件所在目录添加到系统PATH环境变量中,帮助库自动识别路径。

内容的提问来源于stack exchange,提问作者glitch_123

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 07:45:14