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

Python Undetected Chromedriver运行报错TypeError求助

解决Undetected Chromedriver运行时的TypeError问题

问题分析

报错TypeError: argument of type 'NoneType' is not iterable出现在subprocess模块处理启动参数时,通常是因为undetected-chromedriver与Python 3.7 32位版本兼容性不匹配,或参数传递异常导致。

解决方案

1. 安装适配旧Python版本的undetected-chromedriver

Python 3.7 32位属于较老版本,新版本的undetected-chromedriver已不再支持该环境。建议安装兼容版本:

pip uninstall undetected-chromedriver -y
pip install undetected-chromedriver==3.5.3

2. 使用undetected-chromedriver自带的Options类

避免混用selenium的ChromeOptions,改用库自身的Options类减少参数冲突:

import undetected_chromedriver as uc

option = uc.ChromeOptions()
option.add_experimental_option("excludeSwitches", ["enable-automation", "enable-logging"])
driver = uc.Chrome(options=option)

3. 手动指定Chrome可执行文件路径

若系统未自动识别Chrome路径,会导致启动参数传递None,需手动指定:

import undetected_chromedriver as uc

option = uc.ChromeOptions()
option.add_experimental_option("excludeSwitches", ["enable-automation", "enable-logging"])
# 替换为你的Chrome实际安装路径
driver = uc.Chrome(options=option, executable_path="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe")

4. 清理ChromeDriver缓存

undetected-chromedriver自动下载的ChromeDriver缓存可能损坏,删除后重新生成:

  • 找到Windows缓存目录:C:\Users\<你的用户名>\.undetected_chromedriver
  • 删除该目录下所有文件,重新运行代码

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 09:10:37