cx_Freeze可执行文件中的语法无效

时间:2017-12-05 23:22:09

标签: python tkinter cx-freeze

我在windows中制作了一个tkinter应用程序,现在我想制作一个可执行版本。 multiframe.py包含tkinter应用程序的所有代码。

但是当我尝试构建它时,我总是遇到语法错误,但我不明白为什么。这是一个cmd快照。 enter image description here

这就是我的setup.py的样子:

kCVPixelFormatType_DisparityFloat16

1 个答案:

答案 0 :(得分:2)

您的代码中

iconoptions cx_Freeze.Executable(),但未传递给它。他们需要"frame.py",就像executables = cx_Freeze.Executable("frame.py", base=base, icon='ds.ico') 一样使用:

cx_Freeze.setup(options = ...

"packages"中,您首先添加字典键"build_exe"作为字典键include_files的值的一部分但突然之间您尝试添加列表{{1}在字典内部,而不是一个键,它是"packages""build_exe"键旁边的值的一部分。这很难描述。反正。

您的整个代码应如下所示:

import cx_Freeze, sys

base = None

if sys.platform == 'Win32':
    base = "Win32GUI"

executables = cx_Freeze.Executable("frame.py", base=base, icon='ds.ico')

cx_Freeze.setup(
        name="cYou",
        options = {"build_exe": {"packages":["tkinter"], "include_files":["ds.ico"]}},
        version= "0.01",
        description = "dasdasd",
        executables = executables
        )

以下是我用于tkinter的内容。我只是把我的tkinter脚本something.py放在这个脚本旁边。然后我只回复它something。可能需要进行一些修改才能包含图标文件等:

from cx_Freeze import setup, Executable
import sys, os

fileName = input("What's the name of the py file to be converted to .exe?\n")
sys.argv.append('build')

os.environ['TCL_LIBRARY'] = r'C:\Users\username\AppData\Local\Programs\Python\Python36\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\username\AppData\Local\Programs\Python\Python36\tcl\tk8.6'

base = None
if (sys.platform == "win32"):
    base = "Win32GUI"    # Tells the build script to hide the console.
elif (sys.platform == "win64"):
    base = "Win64GUI"    # Tells the build script to hide the console.



setup(
    name='KutsalAklinNerde?',
    version='0.1',              #Further information about its version
    description='Parse stuff',  #It's description
    executables=[Executable(fileName + ".py", base=base)])