How to make exe of pygame

Question:

I’ve finished developing my game in pygame and I want to make a exe of it so I can share it. I tried using cx_Freeze for making exe but in that tutorial he just added only single image and I was confused how I must add these many sprites in a single line I followed this tutorial – https://www.youtube.com/watch?v=BIWqt6NICrw&t=49s

In this tutorial he adds only single image file since his game is too small. So I tried different ways. I tried this method – How can I convert pygame to exe? But its too complex and when I try to perform it I get so many syntax error (I tried that method 10 times)

All I can see there is only one way left to develop exe of my pygame using cx_Freeze but I don’t know how to do so. And I’m using python3 (ver:3.7.3)

Can anyone explain me step by step how to make game using cx_Freeze (please also let me know how to add multiple images since i got so many images (sprites) each for different enemies and hero)

Asked By: hotstepper

||

Answers:

According to this website
https://pythonprogramming.net/converting-pygame-executable-cx_freeze/
You can use a module called cx_Freeze which is similar to py2exe.
Some of the steps are similar to py2exe
And all the instructions are on the website.

Answered By: Aakash Mehta

Pyinstaller is also being used to make exe, I don’t know if it will help in your case or not.

Answered By: Muhammad Adeel

This has already been answered a few times before, converting a pygame to exe is same as converting other python gui applications.

a link to one of the previous questions:
Create a directly-executable cross-platform GUI app using Python

A addition to the Aakash Mehta’s answer, relating to this link: https://pythonprogramming.net/converting-pygame-executable-cx_freeze/

If you want to add more files, you need to add them to the include list:

cx_Freeze.setup(
name="A bit Racey",
options={"build_exe": {"packages":["pygame"],
                       "include_files":["racecar.png", "add_files.png", "one_more.png"]}}, # This line
executables = executables)
Answered By: Mattias
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.