首页 > 其他 > 详细

pyinstaller 打包 sentry_sdk 出现 ModuleNotFoundError 的解决方法

时间:2020-06-03 10:36:45      阅读:150      评论:0      收藏:0      [点我收藏+]

问题背景

我使用 pyqt 在开发一款跨平台的文件检索工具,使用 pyinstaller 打包依赖。为了更好的统计程序的 崩溃日志,决定使用 sentry 来自动化收集。

使用共有云的方案,安装 sentry 官方给的 demo 程序很快就跑通了。使用 pyinstaller 可以成功打包,但程序无法启动,日志报错为

解决过程

ModuleNotFoundError: No module named ‘sentry_sdk.integrations.logging

根据错误提示在 pyinstaller脚本中加入隐含导入

pyinstaller --hidden-import sentry_sdk.integrations.logging

再次打包并运行,又提示缺乏 sentry_sdk.integrations.stdlib, 手动将此依赖写入 pyinstaller 脚本中再次提示缺乏sentry_sdk.integrations.deque

 

 

没完没了了,通过错误关键字找到了这个 pyinstaller-issue-4755 引到了 pyinstaller 的官方文档

我尝试使用 pyinstaller --hidden-import sentry_sdk.integrations.* 却发现 pyinstaller 在打包时提示 无法分析 sentry_sdk.integrations.*

 

 

中间搜索了很多,最后得到此方案

在 pyinstaller 统计目录下编辑一个文件 hook-sentry_sdk.integrations.py写入这些东西

hiddenimports = [
    sentry_sdk.integrations.argv,
    sentry_sdk.integrations.logging,
    sentry_sdk.integrations.stdlib,
    sentry_sdk.integrations.threading,
    sentry_sdk.integrations.atexit,
    sentry_sdk.integrations.rq,
    sentry_sdk.integrations.trytond,
    sentry_sdk.integrations.excepthook,
    sentry_sdk.integrations.modules,
    sentry_sdk.integrations.dedupe
]

 

为 pyinstaller 增加一条打包参数 

--additional-hooks-dir .

问题解决了

参考链接

PyInstaller 系列 - Hook 机制

pyinstaller 打包 sentry_sdk 出现 ModuleNotFoundError 的解决方法

原文:https://www.cnblogs.com/albertofwb/p/13032114.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!