Python cx_冻结可执行文件处的语法无效

Python cx_冻结可执行文件处的语法无效,python,tkinter,cx-freeze,Python,Tkinter,Cx Freeze,我在windows中制作了一个tkinter应用程序,现在我想制作一个可执行版本。multiframe.py包含tkinter应用程序的所有代码 但当我试图构建它时,我总是会遇到语法错误,但我不明白为什么。这是一个cmd快照。 这就是my setup.py的外观: import cx_Freeze base = None if sys.platform == 'Win32': base = "Win32GUI" executable

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

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

这就是my setup.py的外观:

    import cx_Freeze

    base = None

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

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

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

base
icon
cx\u Freeze的
选项。可执行文件在代码中不会传递给它。它们需要在
()
中,就像
“frame.py”
是这样使用的:

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

cx\u Freeze.setup(options=…
中,您首先添加一个字典键
“packages”
,作为字典键
“build\u exe”
值的一部分,但突然间,您尝试添加一个列表
include\u files
,而不是一个仍在字典中的键,该字典键是
旁边的值的一部分“packages”
“build\u 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)])

base
icon
cx\u Freeze.可执行文件的
选项,它们不会被传递到代码中。它们需要位于
()
中,就像
“frame.py”
一样,因此使用:

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

cx\u Freeze.setup(options=…
中,您首先添加了一个字典键
“packages”
,作为字典键
“build\u exe”
值的一部分,但是突然间,您尝试添加一个列表
include\u files
,而不是一个仍在字典中的键,该字典是
旁边的值的一部分将“
打包到
“build\u 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)])

谢谢你的快速回答!现在我没有语法错误,但这是:self.executables=list(executables)TypeError:“Executable”对象不是iterable我不太确定发生了什么,但我使用生成了用于exe转换的脚本。我的是:)您发送的那个也适用于tkinter吗?我也使用了一些修改。更新了我的答案以包含我使用的内容。谢谢!有一件事:executables变量需要是一个列表谢谢您的快速回答!现在我没有语法错误,但是这个:self.executables=list(executables)TypeError:“可执行文件”对象不是iterableI我不确定发生了什么,但我使用生成了用于exe转换的脚本。我的脚本是:)你发送的那个也可以用tkinter吗?我也用了一些修改。更新了我的答案以包含我使用的内容。谢谢!有一件事:executables变量需要是一个listalways将错误消息作为文本,而不是屏幕截图。我们不能从屏幕截图复制文本用于应答或在Google中搜索。始终将错误消息作为文本,不是截图。我们不能从截图中复制文本用于应答或在谷歌中搜索。