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

使用Camelot提取PDF表格时遇WinError 10061连接拒绝错误求助

解决Camelot提取PDF表格时的WinError 10061错误

原因分析

WinError 10061是目标机器主动拒绝连接,结合你之前遇到的Ghostscript问题,核心原因是Camelot依赖的Ghostscript未正确安装或配置,导致程序调用Ghostscript时失败,被误判为网络连接异常。

修复步骤

  • 重新安装并配置Ghostscript环境变量

    1. 下载与你的Python环境(32/64位)匹配的Ghostscript安装包,安装时勾选「Add Ghostscript to system PATH」选项
    2. 若安装时未勾选,手动将Ghostscript的bin目录(如C:\Program Files\gs\gs10.02.1\bin)添加到系统环境变量PATH中
    3. 重启Python环境或终端,确保环境变量生效
  • 在代码中指定Ghostscript路径
    如果环境变量配置无效,可直接在代码中指定路径:

    import camelot
    import os
    
    # 替换为你的Ghostscript实际bin目录路径
    os.environ['PATH'] += os.pathsep + r'C:\Program Files\gs\gs10.02.1\bin'
    tables = camelot.read_pdf("uploaded_document.pdf", pages="all")
    
  • 升级Camelot到最新版本
    旧版本可能存在兼容性问题,执行以下命令升级:

    pip install --upgrade camelot-py[cv]
    

    注:[cv]用于安装表格提取所需的OpenCV依赖组件

  • 验证Ghostscript可用性
    打开命令提示符,输入gswin64c(64位系统)或gswin32c(32位系统),若能进入Ghostscript交互界面,说明安装配置正确;若提示「找不到命令」,需重新检查环境变量。

额外排查项

  • 确认PDF文件未损坏,用常规PDF阅读器打开验证
  • 若开启了代理,暂时关闭代理或添加本地地址到代理白名单(此情况较少见,优先排查Ghostscript)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 02:05:18