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

PyInstaller打包exe后导入pandas遇DLL加载失败(分页文件过小)求助

解决PyInstaller打包后pandas DLL加载失败(分页文件不足)的方案
  • 调整系统虚拟内存
    错误提示直接指向分页文件过小,先搞定系统层面的设置:
    右键「此电脑」→「属性」→「高级系统设置」→「高级」→「性能」→「设置」→「高级」→「虚拟内存」→「更改」
    取消「自动管理所有驱动器的分页文件大小」,选中系统盘,设自定义大小:初始值设为物理内存的1.5倍,最大值设为3倍(比如8G内存就填12288MB和24576MB),保存后重启电脑。

  • 优化PyInstaller打包参数
    减少打包后的资源占用,避免内存加载冲突:

    • 排除不需要的模块,比如没用到的tkinter、matplotlib:
      pyinstaller --onefile --exclude-module tkinter --exclude-module matplotlib your_script.py
      
    • 不需要控制台的话加--noconsole:
      pyinstaller --onefile --noconsole your_script.py
      
    • 给multiprocessing加启动支持,在脚本开头加这段代码:
      from multiprocessing import freeze_support
      
      if __name__ == '__main__':
          freeze_support()
          # 你的主程序逻辑
      
  • 切换pandas版本
    部分pandas版本和PyInstaller、Windows环境不兼容,换个稳定版试试:

    pip uninstall pandas -y
    pip install pandas==1.5.3
    

    重装后重新打包测试。

  • 强制收集pandas所有依赖
    用--collect-all让PyInstaller完整收集pandas的DLL和依赖文件:

    pyinstaller --onefile --collect-all pandas your_script.py
    
  • 修复VC++运行库
    pandas依赖微软VC运行库,缺失会导致DLL加载失败:
    下载对应Python版本的「Microsoft Visual C
    Redistributable」(比如Python3.9对应2019版),安装后重启电脑再运行exe。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 20:03:09