首页 > 解决方案 > cx_freeze/PyQt5: pywintypes.error: (2, 'BeginUpdateResource', '系统找不到指定的文件。'

问题描述

我在 Windows 10 上的 python 3.7.6.4 上确实有 cx_freeze 问题(也尝试过 Windows 7 - 同样的错误) - 使用这个 makeexe:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "sys"],
                     "include_files": ["DMCA.ico"]
}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "DMCA",
        version = "0.01",
        description = "DMCA by EP",
        options = {"build_exe": build_exe_options},
        executables = [Executable("DMCA.py", base=base, icon="DMCA.ico")])

我确实得到:

C:\WPy64-3760\Code\09Working>makeexe

C:\WPy64-3760\Code\09Working>C:/WPy64-3760/python-3.7.6.amd64/python MakeExe.py build
running build
running build_exe
copying C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\bases\Win32GUI.exe -> build\exe.win-amd64-3.7\DMCA.exe
copying C:\WPy64-3760\python-3.7.6.amd64\python37.dll -> build\exe.win-amd64-3.7\python37.dll
copying C:\WPy64-3760\python-3.7.6.amd64\VCRUNTIME140.dll -> build\exe.win-amd64-3.7\VCRUNTIME140.dll
error: [WinError 2] Das System kann die angegebene Datei nicht finden: 'build\\exe.win-amd64-3.7\\DMCA.exe'

如果我使用:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "sys"]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "DMCA",
        version = "0.01",
        description = "DMCA by EP",
        options = {"build_exe": build_exe_options},
        executables = [Executable("DMCA.py", base=base)])

错误是:

C:\WPy64-3760\Code\09Working>makeexe

C:\WPy64-3760\Code\09Working>C:/WPy64-3760/python-3.7.6.amd64/python MakeExe.py build
running build
running build_exe
copying C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\bases\Win32GUI.exe -> build\exe.win-amd64-3.7\DMCA.exe
copying C:\WPy64-3760\python-3.7.6.amd64\python37.dll -> build\exe.win-amd64-3.7\python37.dll
copying C:\WPy64-3760\python-3.7.6.amd64\VCRUNTIME140.dll -> build\exe.win-amd64-3.7\VCRUNTIME140.dll
Traceback (most recent call last):
  File "MakeExe.py", line 21, in <module>
    executables = [Executable("DMCA.py", base=base)])
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\dist.py", line 348, in setup
    distutils.core.setup(**attrs)
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\dist.py", line 219, in run
    freezer.Freeze()
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\freezer.py", line 617, in Freeze
    self._FreezeExecutable(executable)
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\freezer.py", line 208, in _FreezeExecutable
    self._AddVersionResource(exe)
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\freezer.py", line 143, in _AddVersionResource
    stamp(fileName, versionInfo)
  File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\win32\lib\win32verstamp.py", line 163, in stamp
    h = BeginUpdateResource(pathname, 0)
pywintypes.error: (2, 'BeginUpdateResource', The system cannot find the file specified.)

我怎样才能找到问题?我想冻结的源代码更大;PyQt QmainWindow 和多个使用 matplotlib 3.2.1、pillow 6.2.1、scipy 1.4.1 和 numpy 1.17.4+mkl 的子文件,所以它会压倒这个页面。我还尝试将我的子文件添加到 build_exe_options 作为“包含”并且输出是相同的。

标签: python-3.xpyqt5cx-freeze

解决方案


设置新的 Python 并安装软件包解决了这个问题,但可执行文件无法正常工作。关闭这个问题。


推荐阅读