PyInstaller does not include a pre-compiled bootloader for your platform.
Posted on 2024-03-15 08:43 蝈蝈俊 阅读(139) 评论(0) 编辑 收藏 举报用 PyInstaller 打包python程序时,收到下面错误:
User
140343 INFO: Building PKG because PKG-00.toc is non existent
140344 INFO: Building PKG (CArchive) mainwindow.pkg
215759 INFO: Building PKG (CArchive) mainwindow.pkg completed successfully.
215891 INFO: Bootloader D:\env\fbt\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\runw.exe
215891 INFO: checking EXE
215893 INFO: Building EXE because EXE-00.toc is non existent
215894 INFO: Building EXE from EXE-00.toc
Fatal error: PyInstaller does not include a pre-compiled bootloader for your
platform. For more details and instructions how to build the bootloader see
https://pyinstaller.readthedocs.io/en/stable/bootloader-building.html
在
D:\env\fbt\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel
目录下,可以看到没有runw.exe文件
这是 Windows Defender 防病毒软件把这个文件当病毒啥了。
通过将 PyInstaller 的相关文件或目录添加到 Windows Defender 防病毒软件的排除列表中,以防止其被误报或删除。
在 Windows Defender 中添加排除列表的步骤:
1、打开 Windows Defender 安全中心: 在 Windows 搜索栏中输入“Windows Defender 安全中心”,然后打开它。
2、选择“病毒和威胁防护”: 在 Windows Defender 安全中心界面中,选择“病毒和威胁防护”。
3、选择“管理设置”: 在病毒和威胁防护页面中,向下滚动找到“管理设置”,然后点击它。
4、添加排除项: 在管理设置页面中,向下滚动找到“排除项”,然后点击“添加或删除排除项”。
5、添加文件或文件夹: 在添加或删除排除项页面中,点击“添加排除项”,然后选择“文件”或“文件夹”选项,接着浏览到 PyInstaller 相关的文件或目录。
6、确认添加: 选择要排除的文件或文件夹后,点击“打开”或“选择文件夹”来确认添加。
7、完成: 添加完成后,关闭 Windows Defender 安全中心。
通过执行以上步骤,你可以将 PyInstaller 相关的文件或目录添加到 Windows Defender 防护排除列表中,从而避免它们受到误报或被误删。这样可以确保 PyInstaller 在打包过程中不会受到干扰。
重新安装 PyInstaller
# 卸载
pip uninstall pyinstaller
# 安装
pip install pyinstaller
# 检查
pyinstaller --version
无法成功完成操作,因为文件包含病毒或潜在的垃圾软件
再次编译时,会收到下面错误:
237868 INFO: Copying bootloader EXE to D:\mycode\tanghai\PromoteBot2\dist\mainwindow.exe
Traceback (most recent call last):
File "D:\env\fbt\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 33, in pywin32error
yield
File "D:\env\fbt\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 209, in BeginUpdateResource
return _resource._BeginUpdateResource(filename, delete)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\env\fbt\Lib\site-packages\win32ctypes\core\cffi_resource.py", line 114, in _BeginUpdateResource
result = check_null(
^^^^^^^^^^^
File "D:\env\fbt\Lib\site-packages\win32ctypes\core\cffi_util.py", line 78, in call
self._raise_error(function_name)
File "D:\env\fbt\Lib\site-packages\win32ctypes\core\cffi_util.py", line 89, in _raise_error
raise exception
OSError: [WinError 225] 无法成功完成操作,因为文件包含病毒或潜在的垃圾软件。
During handling of the above exception, another exception occurred:Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code .py", line 228, in console_script_run
File "D:\env\fbt\Scripts\pyinstaller.exe_main.py", line 7, in
File "D:\env\fbt\Lib\site-packages\PyInstaller_main
run()
File "D:\env\fbt\Lib\site-packages\PyInstaller_main.py", line 212, in run
run_build(pyi_config, spec_file, **vars(args))
File "D:\env\fbt\Lib\site-packages\PyInstaller_main_.py", line 69, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "D:\env\fbt\Lib\site-packages\PyInstaller\building\build_main.py", line 1139, in main
build(specfile, distpath, workpath, clean_build)
File "D:\env\fbt\Lib\site-packages\PyInstaller\building\build_main.py", line 1079, in build
exec(code, spec_namespace)
File "D:\mycode\tanghai\PromoteBot2\mainwindow.spec", line 18, in
exe = EXE(
^^^^
File "D:\env\fbt\Lib\site-packages\PyInstaller\building\api.py", line 628, in init
self.postinit()
File "D:\env\fbt\Lib\site-packages\PyInstaller\building\datastruct.py", line 184, in postinit
self.assemble()
File "D:\env\fbt\Lib\site-packages\PyInstaller\building\api.py", line 737, in assemble
self._retry_operation(winresource.remove_all_resources, build_name)
File "D:\env\fbt\Lib\site-packages\PyInstaller\building\api.py", line 1003, in _retry_operation
return func(*args)
^^^^^^^^^^^
File "D:\env\fbt\Lib\site-packages\PyInstaller\utils\win32\winresource.py", line 188, in remove_all_resources
module_handle = win32api.BeginUpdateResource(filename, True) # bDeleteExistingResources=True
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\env\fbt\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 208, in BeginUpdateResource
with _pywin32error():
File "C:\Users\ghj1976\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "D:\env\fbt\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (225, '', '无法成功完成操作,因为文件包含病毒或潜在的垃圾软件。')
解决方法:
禁用实时保护: 在进行打包时,尝试暂时禁用 Windows Defender 的实时保护功能。这可以在 Windows Defender 设置中完成,但请注意在禁用期间,你的计算机可能会更容易受到恶意软件的攻击。