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

PyInstaller打包msgraph-sdk-python-core程序遇azure模块找不到错误求助

解决PyInstaller打包MS Graph脚本exe时的azure模块缺失问题
  • 先排查实际依赖的azure子模块:旧的azure包已被拆分并废弃,msgraph-sdk-python-core实际依赖的是azure-core、azure-identity这类独立子包。可以用pipdeptree | grep msgraph查看依赖链,确认具体需要的azure相关模块。
  • 清理并安装正确依赖:卸载废弃的azure包,安装实际需要的子包:
    pip uninstall azure -y
    pip install azure-identity azure-core
    
  • 调整PyInstaller打包参数:不要只加--hidden-import 'azure',而是指定具体的子模块,比如:
    pyinstaller --hidden-import azure.identity --hidden-import azure.core --hidden-import azure.core.pipeline main.py
    
    或者用--collect-submodules参数批量收集子模块:
    pyinstaller --collect-submodules azure.identity --collect-submodules azure.core main.py
    
  • 用spec文件精准配置(可选):生成spec文件后手动添加依赖,步骤如下:
    1. 生成spec文件:pyi-makespec main.py
    2. 打开生成的main.spec,在hiddenimports列表中添加需要的模块:
      hiddenimports=['azure.identity', 'azure.core', 'azure.core.pipeline.transport']
      
    3. 用spec文件打包:pyinstaller main.spec
  • 确保打包环境一致:使用和开发环境相同的虚拟环境,避免依赖混乱。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 20:15:29