无法修复pywintypes.error:(2,'BeginUpdateResource','系统找不到指定的文件。']

问题描述 投票:0回答:1

我正在尝试构建我的Python应用程序的.exe文件。我已经尝试了多种方法来从Github和Stackoverflow创建安装文件,但我不断遇到这个错误:

pywintypes.error: (2, 'BeginUpdateResource', 'The system cannot find the file specified.')

我正在使用Python 3.6.1和cx_Freeze来构建应用程序。

这里是我尝试过的不同安装文件:

尝试1:

import os.path
from cx_Freeze import setup, Executable  

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

executables = [Executable("myprogram.py", base="Win32GUI")]

options = {
    'build_exe': {

        'include_files': [
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),

        ]
    },

}

setup(
    name="Standalone.exe",
    options=options,
    version="0.1",
    description='Simple tkinter application',
    executables=executables, requires=['cx_Freeze', 'cx_Freeze']
)

尝试2:

from cx_Freeze import setup, Executable
import sys
import os

productName = "My Program"
if 'bdist_msi' in sys.argv:
    sys.argv += ['--initial-target-dir', r'C:\Users\RedCode\PycharmProjects\Standalone' + productName]
    sys.argv += ['--install-script', 'myprogram.py']

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

exe = Executable(
      script="myprogram.py",
      base="Win32GUI",
      targetName="Product.exe"
     )
setup(
      name="Standalone.exe",
      version="1.0",
      author="Me",
      description="Copyright 2012",
      executables=[exe],
      scripts=[
               'myprogram.py'
               ]
      )

尝试3:

import sys
import os
from cx_Freeze import setup, Executable


build_exe_options = {"packages": ["os"], "includes": ["tkinter"]}


def s_SourceFile():
    if (sys.argv[0] == ''):
        return __file__
    else:
        return sys.argv[0]


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

setup(name="Standalone",
      version="0.1",
      description="My GUI application!",
      options={"build_exe": build_exe_options},
      executables=[Executable("myprogram.py", base="Win32GUI", targetName="Standalone.exe")])

尝试4:

application_title = "Car Database"
main_python_file = "cardb.py"

import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(
        name = "myprogram.py",
        version = "0.1",
        description = "Simple embedded database application",
        executables = [Executable("myprogram.py", base = base)])

我也尝试过pyinstaller,但是无论我做什么,它都会不断给我一个元组超出范围的错误,并且我尝试了bbfreeze,但我什至无法安装。我已经检查了文件,一切都在那里,所以我看不到如何仍然可以告诉我找不到指定的文件。

我还能做些什么或如何编辑上述尝试,以便使应用程序实际正确构建?甚至还可以确定缺少哪个文件?

python-3.x build cx-freeze setup.py
1个回答
-1
投票

我在使用python 3.7和cx_freeze 6.1的过程中确实遇到了相同的错误消息-在此期间您有任何解决方案吗? BR

© www.soinside.com 2019 - 2024. All rights reserved.