cx_Freeze ImportError:无法导入名称

发布于 2024-08-20 20:37:13 字数 604 浏览 4 评论 0原文

我正在尝试使用 ttk 模块为 tkinter 中的 GUI 应用程序创建一个适用于 Windows 的可执行文件。我用 cx_freeze 制作了一个 exe,但是当我在控制台中运行该应用程序时,出现以下错误:

    D:\My Dropbox\python\SAR Calculator\src\dist_tk>
Traceback (most recent call last):

  File "C:\Python31\lib\site-packages\cx_Freeze\
7, in <module>

    exec(code, m.__dict__)

  File "sarcalc_tk.py", line 14, in <module>

  File "C:\Python31\lib\tkinter\__init__.py", li

    from tkinter import _fix

ImportError: cannot import name _fix

以下是我的代码中的第 14 行和第 15 行:

import tkinter as tk
import tkinter.ttk as ttk

I'm trying create an executable for Windows for a GUI application in tkinter using the ttk module. I made an exe with cx_freeze, but when I run the app in the console it gives me the following error:

    D:\My Dropbox\python\SAR Calculator\src\dist_tk>
Traceback (most recent call last):

  File "C:\Python31\lib\site-packages\cx_Freeze\
7, in <module>

    exec(code, m.__dict__)

  File "sarcalc_tk.py", line 14, in <module>

  File "C:\Python31\lib\tkinter\__init__.py", li

    from tkinter import _fix

ImportError: cannot import name _fix

Here are lines 14 and 15 from my code:

import tkinter as tk
import tkinter.ttk as ttk

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一梦等七年七年为一梦 2024-08-27 20:37:13

看起来 cx_freeze 没有意识到它应该包含 tkinter._fix 模块,该模块是由 tkinter/__init__.py 有条件导入的。您可以使用 --include-modules 命令行参数或 cx_Freeze.Executableincludes 关键字参数显式包含该模块> 在您的 setup.py

Looks like cx_freeze doesn't realize it should include the tkinter._fix module, which is conditionally imported by tkinter/__init__.py. You can tell it to include that module explicitly with the --include-modules command-line argument, or the includes keyword argument to cx_Freeze.Executable in your setup.py

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文