pyinstaller如何使用tkcalendar模块安装python应用程序?

2024-04-18 18:59:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在使用tkcalendar的pyinstaller在Windows上安装python应用程序。应用程序正在运行,但是TK日历不是的

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


Tags: 模块文件path目录应用程序部件windowslib
2条回答

如果有人发现同样的问题。 在tkcalendar 1.5.0中,导入存在问题日历.py. 在

找到tkcalendar文件夹(可能是/../python/Lib/site packages/tkcalendar)和日历.py为丢失的模块添加额外的导入:

import calendar
from babel.dates import format_date, parse_date, get_day_names, get_month_names
from babel.numbers import *  # Additional Import```

这个问题不是来自tkcalendar,而是PyInstaller没有检测到二级导入。tkcalendar的文档在HowTos部分中解释了解决此问题的方法:

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

or by editing the .spec file:

hiddenimports=["babel.numbers"]

相关问题 更多 >