Issue
I made a game in pygame called Balls to the Walls and I encounter an error when building the program in pyinstaller. I run:
C:\Users\Ben pyinstaller --windowed --icon=logo.ico BallsWalls.py
The output is:
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.')
Any way to fix this at all? I tried other questions and they don't work, so don't flag this as duplicate. This question does not ask multiple questions. It only asks one.
Solution
Make sure you're developing in a folder that your antivirus has been told to ignore.
Microsoft's documentation suggests the following steps on Windows 11:
- Open Start -> Settings -> Privacy & Security -> Virus & threat protection
- Select "manage settings", go to "exclusions", and click "add or remove exclusions".
- Select "Add an exclusion", then select a directory that contains the development work where you don't want Windows Defender interfering with pyinstaller.
You can also temporarily disable the antivirus as a whole.
Answered By - Charles Duffy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.