7

This is a simple question. I have been making a game, and I wanted some of my friends to be able to download it online. Do they have to have pygame and python installed on there computer to download it. The reason I ask is because Im also thinking about releasing it to the general audience and if they can't download because they don't have pygame, well I probably won't get much feedback or success. Thank you.

5 Answers 5

10

Yes users need a Python interpreter and a reference to Pygame to execute your program – since your game is written in Python and uses the third party library Pygame.

That said, you could consider to use

to freeze your Python scripts into an executable and to make a standalone application which your friends could download and execute without having Python and / or Pygame installed on their computers.

The Pygame wiki gives you an example how to compile a Pygame app to a standalone windows application using py2exe.

4
  • Which of these would you recommend? I don't think I can use pyInstaller since it's only for 2.7 and 3.3-3.5 Apr 10, 2016 at 20:10
  • Nvm I guess cx_freeze is the best I can use since I don't use a mac either. Apr 10, 2016 at 20:15
  • Yes here is video tutorial using cx_Freeze ;) Give it a shot :)
    – elegent
    Apr 10, 2016 at 20:17
  • No problem at all ;)
    – elegent
    Apr 10, 2016 at 20:19
2

Well, you can convert it into a .exe file that will work independently on windows operating systems.

The .exe file will contain the python interpreter, all the modules like pygame, and if there are any external files like images, sounds, 3d objects etc, they will be embedded inside the .exe file so that the general audience wont need to install any external softwares and this also makes your game hack proof.

You can see the method of converting it quickly, easily, for free, step-by-step, without learning anything on the answer that I gave here :-

https://stackoverflow.com/a/65035225/13700467

Hope you are successful in compiling it and I would like to try your game.

1

Another way to compile your pygame code into .exe would be to use pyg.exe.

Hope this helps.

0

I'm not sure how to deal with installing python, but I added this bit of code to the beginning of my most recent program which is designed to automatically install pygame on launch through cmd using pip.

import os
try:
    import pygame
except:
    try:
        print("Attempting to install pygame...")
        os.system('py -m pip install pygame')
        import pygame
    except:
        try:
            os.system('python -m pip install pygame')
            import pygame
        except:
            print("Error, failed to install pygame libraries")
            input("Press enter to exit...")
            quit()
0

Same idea as @Kovi Bodek, to try and make Python install pygame. But cleaner.

try:
    import pygame
except ImportError:
    print("Attempting to install pygame...")
    try:
        import pip
    except ImportError:
        print("pip not present to install pygame. Exiting...")
        exit()
    else:
        try:
            pip.main(["install", "pygame"])
        except:
            print("Failed to install pygame with pip. Exiting...")
            exit()
        else:
            print("Installed pygame...")
            import pygame
            del pip # Don't contaminate namespace.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.