如何通过 pyinstaller 使用 tkcalendar 模块安装 python 应用程序? [英] How to install python application with tkcalendar module by pyinstaller?

查看:137
本文介绍了如何通过 pyinstaller 使用 tkcalendar 模块安装 python 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 pyinstaller 在 Windows 上安装 python 应用程序,我正在使用 tkcalendar.应用程序正在运行,但 tkcalendar.Calendar 不起作用.

I'm trying to install python application on Windows with pyinstaller where I'm using tkcalendar. Application is working but the tkcalendar.Calendar isn't.

当我在没有安装的情况下运行应用程序时,一切正常,但如果我这样做,日历小部件不会出现.我认为 pyinstaller 看到了这个模块,但他对 tkcalendar 使用的模块有问题.我尝试使用 --path=/.../python/Lib/site-packages 运行 pyinstaller 但这没有用.将模块文件复制到应用程序目录也无济于事.

When I'm running application without installation everything works but if I do this, Calendar widget does not appear. I think that pyinstaller sees this module but he has problems with modules that tkcalendar is using. I tried to run pyinstaller with --path=/.../python/Lib/site-packages but this didnt worked. Also copying module files to application directory didn't help.

推荐答案

该问题并非来自 tkcalendar,而是 PyInstaller 未检测到二级导入这一事实.在 HowTos 部分的 tkcalendar 文档中解释了解决此问题的方法:

The issue does not come from tkcalendar but from the fact that PyInstaller does not detect second level imports. A way to solve this issue is explained in tkcalendar's documentation in the HowTos section:

使用 PyInstaller 捆绑应用程序时,有一个问题检测 tkcalendar 的 babel 依赖.这可以通过使用 --hidden-import 选项:

When bundling an application with PyInstaller, there is an issue with the detection of the babel dependency of tkcalendar. This can be fixed by using the --hidden-import option:

$ pyinstaller --hidden-import babel.numbers myscript.py

或通过编辑 .spec 文件:

hiddenimports=["babel.numbers"]

这篇关于如何通过 pyinstaller 使用 tkcalendar 模块安装 python 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆