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

PyInstaller打包Google Calendar API项目时出现AttributeError问题求助

解决PyInstaller打包Google Calendar API应用时的AttributeError问题

遇到打包后运行exe出现AttributeError: module 'google.auth.credentials' has no attribute 'CredentialsWithTokenUri'的问题,可尝试以下方案:

  • 添加隐式导入配置
    PyInstaller可能未自动识别google.auth模块的内部子类,需手动指定:

    1. 生成.spec配置文件:pyi-makespec your_app.py
    2. 打开生成的.spec文件,找到hiddenimports参数,补充内容:
      hiddenimports=['google.auth.credentials', 'google.oauth2.credentials']
      
    3. 基于.spec文件重新打包:pyinstaller your_app.spec
  • 升级依赖包
    版本不兼容可能引发该问题,执行命令更新相关依赖:

    pip install --upgrade google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client pyinstaller
    
  • 确保打包环境一致性
    确认打包使用的Python环境(如虚拟环境)与开发环境完全一致,避免依赖版本混乱,激活对应环境后再执行打包命令。

  • 手动补充缺失文件
    若以上方法无效,找到Python site-packages目录下的google/auth/credentials.py文件,将其复制到exe所在目录的google/auth子文件夹中(无该目录则手动创建)。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 16:12:05