如何从 python 文件生成 exe 应用程序

How can I generate the exe application from python file

我正在尝试使用 pyinstaller 从这个脚本中获取 .exe 文件

我在测试目录中使用了这个命令 pyinstaller -w -F test.py

文件 test.py 包含

from tkinter import *
from tkcalendar import DateEntry

root = Tk()
date = DateEntry(root, year=2001, month=11, day=11, width=17,)
date.pack()
root.mainloop()

我得到的 .exe 文件无法运行?

当我这样做时 pyinstaller -F test.py 我在控制台上收到没有名为 babel.numbers 的模块的错误

PyInstaller 似乎无法为 tkcalendar 解析模块 babel.numbers。一种简单的方法是使用 hidden-import:

pyinstaller -F --hidden-import "babel.numbers" test.py