cx_freeze/PyQt5: pywintypes.error: (2, 'BeginUpdateResource', '系统找不到指定的文件。'
Posted
技术标签:
【中文标题】cx_freeze/PyQt5: pywintypes.error: (2, \'BeginUpdateResource\', \'系统找不到指定的文件。\'【英文标题】:cx_freeze/PyQt5: pywintypes.error: (2, 'BeginUpdateResource', 'The system cannot find the file specified.'cx_freeze/PyQt5: pywintypes.error: (2, 'BeginUpdateResource', '系统找不到指定的文件。' 【发布时间】:2020-06-17 08:59:46 【问题描述】:我在 python 3.7.6.4 和 Windows 10 上确实有 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 作为 'includes' 并且输出是相同的。
【问题讨论】:
【参考方案1】:设置新的 Python 并安装软件包解决了这个问题,但可执行文件无法正常工作。关闭此问题。
【讨论】:
以上是关于cx_freeze/PyQt5: pywintypes.error: (2, 'BeginUpdateResource', '系统找不到指定的文件。'的主要内容,如果未能解决你的问题,请参考以下文章
无法修复 pywintypes.error: (2, 'BeginUpdateResource', '系统找不到指定的文件。')
Pyinstaller 不工作 - ImportError: Module 'pywintypes' is not in freeze sys.path
使用 win10toast 时出错:pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')
win32gui.GetPixel() 不工作:pywintypes.error: (0, 'GetPixel', 'No error message is available')
win32ctypes.pywin32.pywintypes.error: (2, ‘LoadLibraryEx‘, ‘系统找不到指定的文件。‘)