【问题标题】:How can I generate the exe application from python file [duplicate]如何从 python 文件生成 exe 应用程序 [重复]
【发布时间】:2019-07-05 12:17:52
【问题描述】:

我正在尝试使用 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 的模块的错误

【问题讨论】:

  • 你试过cx_Freeze
  • 没有。 @RahulAgarwal
  • 我发现它比其他软件包非常简单和更好。在 SO 中有很多相同的答案
  • 我通常使用cx_Freezepy2exenuitkapyInstaller 经常给我带来麻烦。您不能在客户端机器上安装 Python 的任何原因?
  • @AgiHammerthief 你是什么意思你不能在客户端机器上安装 Python 的任何原因?

标签: python pyinstaller tkcalendar


【解决方案1】:

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

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

【讨论】:

  • 使用 virtualenv 安装 Pyinstaller 和 tkcalendar。另外,将print 语句放在第一行并确保您在控制台输出中看到它(记住**不要使用-w 标志)。
  • 感谢它在没有虚拟环境的情况下工作
猜你喜欢
  • 2012-09-21
  • 1970-01-01
  • 2010-09-08
  • 1970-01-01
  • 1970-01-01
  • 2017-03-05
  • 2020-12-05
相关资源
最近更新 更多