我在构建安装程序时遇到了麻烦。我每次尝试都犯了这个错误。。。pywintypes.error:(2,'BeginUpdateResource','Le fichier spéspecifiéest intruvable'(我搞不明白这个错误是为什么和从哪里来的?如果有人能向我解释,我将不胜感激!
from cx_Freeze import setup, Executable
import os.path
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
options = {
'build_exe': {
'include_files':[
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
],
},}
includefiles = ["logo.ico", "image.gif"]
target = Executable(
script = "Livre de Compte Bêta.py",
copyright= "Copyright © 2020",
icon = "logo.ico",
base = "Win32GUI")
setup(
name = "Livre de Compte",
version = "0.1" ,
description = "options = {'build_exe': {'include_files':includefiles}}, executables = [target]",
)
指令:
- 根据文件位置更改
tcl
和tk
目录 - 用
.pyw
更改可执行文件扩展名,这将在运行.exe
时隐藏控制台窗口 - 根据示例删除或添加任何额外的文件或文件夹
- 只需根据需要运行
setup.py
- 额外提示:您可以使用
inno setup
设计安装程序
您可以在评论中讨论额外的问题。
你可以试试这个脚本:
import cx_Freeze
import sys
import os
base = None
if sys.platform == 'win32':
base = "Win32GUI"
os.environ['TCL_LIBRARY'] = r"C:PythonPython 3.7tcltcl8.6" # Path of tcl
os.environ['TK_LIBRARY'] = r"C:PythonPython 3.7tcltk8.6" # Path of tk
executables = [cx_Freeze.Executable("app.pyw", # Executable file with .pyw extension
base=base,
icon="Imageshield.ico" # Path of icon
)]
cx_Freeze.setup(
name="Name", # Name of the app
options={"build_exe": {"packages": ["tkinter", "os"],
"include_files": ['tcl86t.dll',
'tk86t.dll',
'Image']}}, # Extra file or folder
description="Write about your app",
executables=executables
)
# Run this command python setup.py bdist_msi, if you want installer and exe
# Run this command python setup.py build, if you want exe only