This error is not an error specific to Python. This is a warning the Windows 10 operating system gives the user when they attempt to run usually two kinds of programs:
A program deemed malicious by Windows
A program built on 64-bit system that is trying to run on a 32-bit system.
My guess is most likely option #2. There is nothing wrong with your code. But from what you described, this sounds like a problem with your usage of Pyinstaller. The way Pyinstaller builds programs is clever, but it depends on the system you built it on. For example, if you built the program on Windows 7, you will likely have problems running it on Windows 10.
See:
https://pyinstaller.readthedocs.io/en/stable/usage.html
So when distributing your program in this case, you are running into issues because you failed to target something about your friend's set up. Like if you used a 64-bit version of Python to freeze your script, and your friend is trying to run it on a 32-bit system. More details are needed to properly help you--like the version of Windows you built it on versus that of your friend.