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

米琪卡哇伊
TA贡献1998条经验 获得超6个赞
问题不是来自于tkcalendar
PyInstaller 没有检测到二级导入这一事实。tkcalendar 的HowTos文档中解释了解决此问题的方法:
使用 PyInstaller 捆绑应用程序时, 检测 tkcalendar 的 babel 依赖存在问题。这可以通过使用以下
--hidden-import
选项来解决:$ pyinstaller --hidden-import babel.numbers myscript.py或通过编辑.spec文件:
hiddenimports=["babel.numbers"]

慕桂英3389331
TA贡献2036条经验 获得超8个赞
如果有人发现同样的问题。在 tkcalendar 1.5.0 中,在 calendar.py 中导入存在问题。
找到tkcalendar文件夹(可能是 /.../python/Lib/site-packages/tkcalendar)并在calendar.py下为缺少的模块添加一个额外的导入:
import calendar
from babel.dates import format_date, parse_date, get_day_names, get_month_names
from babel.numbers import * # Additional Import```
添加回答
举报
0/150
提交
取消