我在 pygame 中制作了一个名为 Balls to the Walls 的游戏,在 pyinstaller 中构建程序时遇到错误。我跑:
C:\Users\Ben pyinstaller --windowed --icon=logo.ico BallsWalls.py
输出是:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "B:\Python Installs\Python 3.11.6\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\__main__.py", line 205, in _console_script_run
run()
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\__main__.py", line 189, in run
run_build(pyi_config, spec_file, **vars(args))
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\__main__.py", line 61, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\building\build_main.py", line 1033, in main
build(specfile, distpath, workpath, clean_build)
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\building\build_main.py", line 973, in build
exec(code, spec_namespace)
File "C:\Users\Student\Balls to the Walls\BallsWalls.spec", line 18, in <module>
exe = EXE(
^^^^
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\building\api.py", line 625, in __init__
self.__postinit__()
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__
self.assemble()
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\building\api.py", line 738, in assemble
self._retry_operation(icon.CopyIcons, build_name, self.icon)
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\building\api.py", line 992, in _retry_operation
return func(*args)
^^^^^^^^^^^
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\utils\win32\icon.py", line 209, in CopyIcons
return CopyIcons_FromIco(dstpath, [srcpath])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\PyInstaller\utils\win32\icon.py", line 143, in CopyIcons_FromIco
hdst = win32api.BeginUpdateResource(dstpath, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 208, in BeginUpdateResource
with _pywin32error():
File "B:\Python Installs\Python 3.11.6\Lib\contextlib.py", line 155, in __exit__
self.gen.throw(typ, value, traceback)
File "B:\Python Installs\Python 3.11.6\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (225, 'BeginUpdateResourceW', 'Operation did not complete successfully because the file contains a virus or potentially unwanted software.')
有什么办法可以解决这个问题吗? 我尝试了其他问题,但它们不起作用,所以不要将其标记为重复。这个问题不会问多个问题。它只要求一个。
确保您正在一个防病毒软件已被告知忽略的文件夹中进行开发。
Microsoft 的文档 建议在 Windows 11 上执行以下步骤:
您也可以暂时禁用整个防病毒软件。