cx_Freeze ImportError:无法导入名称
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 cx_freeze 没有意识到它应该包含 tkinter._fix 模块,该模块是由 tkinter/__init__.py 有条件导入的。您可以使用
--include-modules
命令行参数或cx_Freeze.Executable
的includes
关键字参数显式包含该模块> 在您的setup.py
中Looks like cx_freeze doesn't realize it should include the
tkinter._fix
module, which is conditionally imported bytkinter/__init__.py
. You can tell it to include that module explicitly with the--include-modules
command-line argument, or theincludes
keyword argument tocx_Freeze.Executable
in yoursetup.py