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

如何解决undetected_chromedriver启动时的HTTPError 404错误?

问题

运行Python代码执行driver = uc.Chrome(options=opts)启动undetected_chromedriver时,出现404错误,完整报错信息如下:

Traceback (most recent call last):
  File "C:\Users\nenuk\OneDrive\Desktop\Creator\32.py", line 556, in <module>
    driver = uc.Chrome(options=opts)
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\site-packages\undetected_chromedriver\__init__.py", line 258, in __init__
    self.patcher.auto()
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\site-packages\undetected_chromedriver\patcher.py", line 178, in auto
    self.unzip_package(self.fetch_package())
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\site-packages\undetected_chromedriver\patcher.py", line 287, in fetch_package
    return urlretrieve(download_url)[0]
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 240, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 521, in open
    response = meth(req, response)
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 630, in http_response
    response = self.parent.error(
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 559, in error
    return self._call_chain(*args)
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain
    result = func(*args)
  File "C:\Users\nenuk\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

此前通过重新下载相关内容解决过,但现在该方法失效,求解决办法。

解决方案

  • 指定本地ChromeDriver路径:手动下载和本地Chrome版本完全匹配的ChromeDriver,初始化时直接指定路径跳过自动下载。示例代码:

    import undetected_chromedriver as uc
    
    opts = uc.ChromeOptions()
    # 添加你的自定义配置
    driver = uc.Chrome(options=opts, executable_path=r"C:\your\chromedriver\path\chromedriver.exe")
    

    Chrome版本可在「Chrome设置-关于Chrome」中查看。

  • 更新undetected_chromedriver:旧版本的下载链接可能已失效,执行命令升级到最新版:

    pip install --upgrade undetected-chromedriver
    
  • 清除自动下载缓存:缓存文件损坏或路径错误也会导致404,找到缓存目录删除所有文件后重试:

    • Windows系统缓存路径一般为C:\Users\<你的用户名>\AppData\Local\undetected_chromedriver
  • 检查网络环境:404可能是网络无法访问默认下载源,可切换网络(如手机热点)或关闭代理后重试。

  • 固定Chrome版本:关闭Chrome自动更新功能,暂时固定浏览器版本,确保和undetected_chromedriver支持的版本一致。

内容的提问来源于stack exchange,提问作者i wish i knew

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 20:23:17