2017-02-14 52 views
2

我是Python新手。我正在尝试使用cx_freeze创建可执行文件,但是在创建该文件后,exe无法启动。我收到以下错误: Error messagecx冻结可执行文件无法启动导入_tkinter#如果失败您的python可能没有配置为tk

我使用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中创建exe的py?

+0

对不起,我在第一篇文章中犯了一个错误。代码实际上是: 从Tkinter的进口* 从Tkinter的进口的MessageBox 随机进口消息 = [ '!рекриейтнитамнещо',] #答案=(消息[random.randint(0,LEN(消息) - 1 )]) 顶部= Tk的() top.title( “随机布尔什特GEN”) top.geometry( “200x180”) DEF helloCallBack(): 味精= messagebox.showinfo( “!射击”,(消息B = Button(top,text =“Blind shot me now!”,command = helloCallBack) B.config(height = 3,width = 15) B.place(x = 50,y = 50) top.mainloop() – Val

+0

您是否尝试过此解决方案 - https://stackoverflow.com/a/42357202/7046074。 –

回答

0

我有完全一样的问题,并通过手动复制以下DLL中的EXE目录解决它:

  • %PYTHON%\ DLL文件\ tcl86t.dll
  • %PYTHON%\ DLL文件\ tk86t。 dll
相关问题