cx冻结可执行文件没有启动导入_tkinter#如果失败你的python可能没有为tk配置

时间:2017-02-14 14:41:08

标签: executable cx-freeze

我是Python新手。我正在尝试使用cx_freeze创建可执行文件但在创建文件后无法启动exe。我收到以下错误: Error message

我正在使用 pytone 3.6.0

代码



import sys
import os
os.environ['TCL_LIBRARY'] = "C:\\Users\\Valeri\\AppData\\Local\\Programs\\Python\\Python36-32\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\\Valeri\\AppData\\Local\\Programs\\Python\\Python36-32\\tcl\\tk8.6"
from cx_Freeze import setup, Executable
# replaces commandline arg 'build'
sys.argv.append("build")  
# change the filename to your program file --->
filename = "SolutionGenerator.py"
base = None
if sys.platform == "win32":
    base = "Win32GUI"
setup(
    name = "Circle",
    version = "1.0",
    description = "cx_Freeze Tkinter script",
    executables = [Executable(filename, base=base)])




setup.py



import sys import os os.environ['TCL_LIBRARY'] = "C:\\Users\\Valeri\\AppData\\Local\\Programs\\Python\\Python36-32\\tcl\\tcl8.6" os.environ['TK_LIBRARY'] = "C:\\Users\\Valeri\\AppData\\Local\\Programs\\Python\\Python36-32\\tcl\\tk8.6" from cx_Freeze import setup, Executable "SolutionGenerator.py" base = None if sys.platform == "win32":
    base = "Win32GUI" setup(
    name = "Circle",
    version = "1.0",
    description = "cx_Freeze Tkinter script",
    executables = [Executable(filename, base=base)])




我尝试了我在互联网上找到的所有内容,但无法使这个exe工作。 在Python 3.6中是否还有其他可能从py创建exe?

1 个答案:

答案 0 :(得分:0)

我有完全相同的问题,并通过在exe目录中手动复制以下dll来解决它:

  • %PYTHON%\的DLL \ tcl86t.dll
  • %PYTHON%\的DLL \ tk86t.dll