I’m trying to turn my Python file into .exe by using the command prompt, and this keeps happening.

C:UsersAdmin>pyinstaller --onefile -w q2.py
406 INFO: PyInstaller: 6.3.0
406 INFO: Python: 3.12.0
515 INFO: Platform: Windows-10-10.0.19045-SP0
515 INFO: wrote C:UsersAdminq2.spec
531 INFO: Extending PYTHONPATH with paths
['C:\Users\Admin']
pygame 2.5.2 (SDL 2.28.3, Python 3.12.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
1312 INFO: checking Analysis
1374 INFO: checking PYZ
1405 INFO: checking PKG
1468 INFO: Bootloader C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerbootloaderWindows-64bit-intelrunw.exe
1468 INFO: checking EXE
1468 INFO: Building EXE because EXE-00.toc is non existent
1468 INFO: Building EXE from EXE-00.toc
1484 INFO: Copying bootloader EXE to C:UsersAdmindistq2.exe
1671 INFO: Copying icon to EXE
Traceback (most recent call last):
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packageswin32ctypespywin32pywintypes.py", line 33, in pywin32error
    yield
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packageswin32ctypespywin32win32api.py", line 209, in BeginUpdateResource
    return _resource._BeginUpdateResource(filename, delete)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packageswin32ctypescorectypes_util.py", line 39, in check_null
    raise make_error(function, function_name)
OSError: [WinError 225] Operation did not complete successfully because the file contains a virus or potentially unwanted software.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Scriptspyinstaller.exe__main__.py", line 7, in <module>
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstaller__main__.py", line 214, in _console_script_run
    run()
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstaller__main__.py", line 198, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstaller__main__.py", line 69, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerbuildingbuild_main.py", line 1071, in main
    build(specfile, distpath, workpath, clean_build)
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerbuildingbuild_main.py", line 1011, in build
    exec(code, spec_namespace)
  File "C:UsersAdminq2.spec", line 18, in <module>
    exe = EXE(
          ^^^^
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerbuildingapi.py", line 628, in __init__
    self.__postinit__()
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerbuildingdatastruct.py", line 184, in __postinit__
    self.assemble()
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerbuildingapi.py", line 741, in assemble
    self._retry_operation(icon.CopyIcons, build_name, self.icon)
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerbuildingapi.py", line 1003, in _retry_operation
    return func(*args)
           ^^^^^^^^^^^
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerutilswin32icon.py", line 209, in CopyIcons
    return CopyIcons_FromIco(dstpath, [srcpath])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packagesPyInstallerutilswin32icon.py", line 143, in CopyIcons_FromIco
    hdst = win32api.BeginUpdateResource(dstpath, 0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packageswin32ctypespywin32win32api.py", line 208, in BeginUpdateResource
    with _pywin32error():
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libcontextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "C:UsersAdminAppDataLocalProgramsPythonPython312Libsite-packageswin32ctypespywin32pywintypes.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.')

0

Try running it with windows defender real time protection turned off