I have created a pygame application and I want to send it to my peers through email. I used cx_Freeze to create executable file. I followed https://pythonprogramming.net/converting-pygame-executable-cx_freeze/ to create the file. It runs perfectly on my laptop but when I zip the entire folder and send it to someone through email and ask them to run on their PC, the executable file crashes by displaying a command window which runs for 1 second and it is unable to view the error. I used the code for creating executable.
import cx_Freeze
import os
executables = [cx_Freeze.Executable("my_file.py")]
cx_Freeze.setup(
name="Sample Program",
options={"build_exe": {"packages":["pygame"],
"include_files":[os.path.abspath(os.getcwd()) +"\\my_image.png",
os.path.abspath(os.getcwd()) + "\\data\\"]}},
executables = executables
)
I do not want them to go through any installation process for Python or Pygame. How can I fix this and make it run in every other PC ?
.zip
You should use PyInstaller instead of cx_Freeze: you just need to type one line of code in the command prompt, you don't need any other file, and you have the possibility to convert your .py
/.pyw
file into only one .exe
file, without a whole bunch of other files.
This way you can't miss any file in the .zip
.
To avoid that issue, you can either:
.exe
from a win32 computer.