Game Development in Python 3 With PyGame - 16 - Convert to executable

preview_player
Показать описание


In this PyGame with Python 3 programming tutorial, we cover how we can convert our PyGame into an executable, or an installer, which we can then share with people who do not have Python installed, or pygame... etc. We will do this using cx_Freeze, which is a very similar module to py2exe for those who are familiar.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

6 years later, this is still the best video for turning a pygame script into an executable. I had problems with fonts and included files (art files) and you had solutions for both. Good work!

glennclapp
Автор

OMG after 2 hours of trying i found your tutorial and worked at the first try, BIG THANKS MAN

klanehz
Автор

If you run the .exe via CMD, you can see the errors because the prompt wont quit. At least it works here on win7. Love your videos dude, never stop teaching.

andrecruzrodrigues
Автор

If you have - KeyError: 'TCL_LIBRARY' add these lines on top of your setup py:
import os
os.environ['TCL_LIBRARY'] = "C:\\Program Files
os.environ['TK_LIBRARY'] = "C:\\Program Files
The paths and "tk/tcl" versions may vary.

If you have - AttributeError: 'NoneType' object has no attribute 'split', add something like version="22.99", to cx_Freeze.setup()

hidanjamanako
Автор

Seriously after 6 years and it helped me in making exe of my programming language

abduksam
Автор

MY BRO! I have been trying to do this in thousand of ways!! And this one really worked! I own you a lot! Thank you!!

diegobolanosp.
Автор

Great videos! Awesome to finally find someone who make tutorials of more in-depth things than just the basics in a language. A suggestion of a series would be to create a more in-depth program/game (small RPG or something for example) to show how to structure a program/game on a larger scale. For example, how to correctly structure the different classes and refer to them correctly in a main program.

Jonte
Автор

+max lloyd add Python to your path or just do something like C:/Python34/python setup.py build

sentdex
Автор

How dumb i am !! I was searching this from last 3 days... just found here and it worked perfectly. Thank you :-)

razaulkarim
Автор

had no problems setting up the build and dist. very good video. good to see the trial and error process. DS

drewsullivan
Автор

You answered all of the questions, searching for months. Thank you.

sourabhbhandary
Автор

Well... This kind of conversion is unpredictable sometimes. I had this error that says that my file can not be opened but i was pretty sure that everything was ok, and after a long time trying to fix this, i tried to copy the "png" files to the executable folder, then worked just fine! I don't know if anyone else had this problem as i had. So that's a tip :) And thank you so much for the excellent tutorials!

polino
Автор

As of this day, I had issues using Christopher's cx_Freeze with Python3.5, so I just downloaded Python3.4 instead. I also had to get pygame for 3.4 and cx_Freeze 4.3.4 for 3.4. When I got those in the correct directories I was then able to create an exe and a distro. So take into consideration if anyone is using Python3.5. I was able to use 32-bit versions on my 64-bit OS, but if you tried 64-bit on a 32-bit OS this would not have worked. Great tutrorials I am loving Python! :D

aaronsanders
Автор

18: 17 WOW that "bdist_msi" was really useful. It's exactly what I've wanted!

vilvero
Автор

cx_freeze 6.2 sometimes has a bug during the build, "expected str" -> you can pip install 6.1 and it will work just fine. Also, for including a complete folder of sprites, you can use "include_files": ["your_folder_name/"] and just drop everything inside. Works for windows.

alexb
Автор

These tutorials are great! I used this to make my own game into an executable. Thanks!

aritrosaha
Автор

After a week of various random errors and googling to try to convert this in 2017, I finally fixed what was happening which seemed to resolve the errors not letting me run after the build. Here's a few tips that worked for me and hopefully will work for someone else struggling to get their game up and running. I'm using python 3.4.1 with corresponding pygame, cx_Freeze 5.0.1 which was just released jan 2017. I couldn't tell you about other versions of other things, this is what I did with what I have. These changes were made in my main.py

1)I changed the starter lines to include other modules as well as initialize fonts so it now looks like this:
import pygame
import time
import random
import re
from pygame.locals import *

pygame.init()
pygame.font.init()

2) Anywhere I needed to call fonts were changed to this and be sure to only have the ' ' instead of " " when surrounding the font types with the number being whatever size fits your display the way you want

pygame.font.SysFont('verdana', 72)

Again, I'm not exactly sure yet why this cleared everything up. My errors that I kept getting included os not reading the font, segmented file errors, implementation errors, etc....pretty much all described below. Hope this helps at least 1 person! I'm off to start the next in the series....great job again sentdex I'm still with you!

harri
Автор

Your video is the best tutorial video of all youtubers!!!!1

juozapasjurksa
Автор

your awesome from your tutorial i was able to make a fully functional menu for my checkers game . i am going to constantly on this now

markblake
Автор

+sentdex I tried using it with Python 3.5 and it says 'KeyError TCL_LIBRARY'. Know anyway to get around this?

KNM
welcome to shbcf.ru