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

时间:2017-05-31 09:13:52

标签: python-3.x build cx-freeze setup.py

我正在尝试构建我的Python应用程序的 116 128 125 125 126 125 126 125 130 124 128 126 131 131 130 131 129 126 146 150 150 152 157 151 157 152 149 145 152 158 151 154 158 153 158 156 145 154 157 154 153 160 152 158 153 149 153 151 156 158 152 157 152 156 151 152 154 152 158 151 154 150 151 147 160 156 157 154 154 152 152 153 150 157 150 152 151 149 151 156 154 文件。我已经尝试了各种方法从Github和Stackoverflow创建一个安装文件,我不断收到同样的错误:

.exe

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

以下是我尝试过的不同设置文件:

尝试1:

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

尝试2:

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']
)

尝试3:

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'
               ]
      )

尝试4:

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")])

我也尝试了pyinstaller,但无论我做什么,它都不断给我一个超出范围错误的元组,我尝试了bbfreeze,我甚至无法安装。我检查了我的文件,一切都在那里,所以我看不出它怎么还能告诉我找不到指定的文件。

我还能做什么或如何编辑上述尝试以便应用程序实际构建正确?有没有办法确定哪个文件丢失了?

2 个答案:

答案 0 :(得分:1)

删除版本,我遇到了同样的错误,查看代码并注意到它引用了源代码中的版本控制,所以我想尝试一下,它为我修复了它。

我知道海报可能不再需要这个了,但是将它发布给将来遇到此问题的其他人,因为我在其他任何地方都没有看到答案。

答案 1 :(得分:0)

cx_Freeze.setup(
name="SampleName",
options={"build_exe": {"packages": ["tkinter", "os"],
                       "include_files": ['tcl86t.dll', 'tk86t.dll', 'closenew.png', 'sujata.png', 'config.py', 'ui_attributes.py']}},
version="0.01", # Remove this line
description="Tkinter Application",
executables=executables
)

我已经删除了该版本并且它有效。

cx_Freeze.setup(
name="SampleName",
options={"build_exe": {"packages": ["tkinter", "os"],
                       "include_files": ['tcl86t.dll', 'tk86t.dll', 'closenew.png', 'sujata.png', 'config.py', 'ui_attributes.py']}},
description="Tkinter Application",
executables=executables
)