Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pyinstaller says I made a virus

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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:

  1. Open Start -> Settings -> Privacy & Security -> Virus & threat protection
  2. Select "manage settings", go to "exclusions", and click "add or remove exclusions".
  3. 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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading