This tutorial goes over the installation and use of PyInstaller for creating executables from Pygame games written in Python.
Пікірлер: 288
@DaFluffyPotato4 жыл бұрын
A couple important notes in case things aren't working: If you use pygame.font.SysFont(None, x), the executable won't work. You can switch out None for 'calibri' or whatever and it'll work. A note for Linux users: I think that pyinstaller sometimes installs as "PyInstaller" with it being case sensitive. If you've got any issues (normally it'll say something like "failed to execute script" or it'll not do anything), take out the --onefile and --noconsole. Then run the executable from the command line to see the error.
@laksanaijampakaew23704 жыл бұрын
Thanks so much about font
@FeverDev644 жыл бұрын
Im having issues. The window and console opens and closes after a few seconds
@gdsupermoonsuperpresents84044 жыл бұрын
It not helped ;-;
@DaFluffyPotato4 жыл бұрын
@@gdsupermoonsuperpresents8404 did you follow the last step?
@gdsupermoonsuperpresents84044 жыл бұрын
@@DaFluffyPotato Ill just making pong, And it have 3 files: ball.py, paddle.py, and main.py, and music
@nyct.o4 жыл бұрын
Just wanted to say thanks for your tutorials, they help so much and they're clear and well made
@seekergx80964 жыл бұрын
Thank you so much for pointing out the problems that might arise every step of the way, saved me so much time just in 6 minutes! Great detail man! +subscribed
@henrypdt4 жыл бұрын
To anyone having the failed execute script one, or pygame.error : Failed loading libmpg123.dll: the specified module could not be found, try changing your pygame.mixer.music.load audio file to .wav instead. It works for me
@stijndcl2 жыл бұрын
@@suvradippaul7843 he literally wrote the solution in the comment
@lightpearl14952 жыл бұрын
I wish I could've seen this comment before struggling for a week :/
@marcsalvado2 жыл бұрын
This is the comment I've been looking for
@JastaCon Жыл бұрын
i have the same problem but my audio-data was wav. from the beginning. so this sadly is no solution to me
@daboxguy38483 жыл бұрын
I feel like I can't escape your tutorials. This is going to be very useful. Thanks 👍
@anonyme894 Жыл бұрын
THANKS A LOT!! Advice : for me I had to change the font from none to 'arial' (whatever non-default font is ok), and add --exclude-module pydoc in pyinstaller line, and it finally worked!! Love, my students will enjoy 😍
@BattleandForge3 жыл бұрын
Made an executable from my first game thanks to this tutorial!
@vitoroliveira83812 жыл бұрын
I'm getting this Traceback (most recent call last): File "client.py", line 1, in import pygame ModuleNotFoundError: No module named 'pygame' [69877] Failed to execute script 'client' due to unhandled exception!
@rickysacco27204 жыл бұрын
Hi… thank for tutorial… I've a question, is possible to converti pygame script with images to an exe that doesn't need image files to work..?
@ОбидинНиколай18 күн бұрын
Hello guys. Please help me, I cannot work in vscode, I have errors with import and when opening pyinstaller, I do not have errors that modules and file are not found main.exe it opens without errors. For example, I have this structure: src/ scripts/ core/ config/ settings.py utils/ debug.py main.py world/ logic.py assets/ And for example my file main.py doesn't know what the import is: from core.config.settings import WINDOW_WIDTH, WINDOW_HEIGHT, FRAME_RATE from world.logic import Level I want to import everything like this src/scripts/ and then what do I need, which file, etc. For example, with the current structure, I have a file main.py (executable file) open the game only after I make the file main.exe and for example, in Visual Studio, Code gives an error about import. What to do, please help.
@bovfbovf3 жыл бұрын
Hey, I love your tutorials, but everytime I try and package a python script in .exe windows defender recognizes it as a virus, do you know any workarounds?
@deveagle36083 жыл бұрын
I don't know any, other than getting a digital license, but just tell the user to ignore it.
@djlazer13 жыл бұрын
The only way is to get a digital signature which costs money. It kinda sucks but at least they can still run it.
@Noober6665 ай бұрын
Turn of windows defender and then turn it back on when ur done
@anamariabalaban2 жыл бұрын
Thanks for the tutorial it helped me a lot. I will look for other tutorials of yours and especially on pygame if you created them. 🤗
@xoxogamewolf75859 ай бұрын
But wait, if you wanted to use pygame with it, but pygame isn't installed on another computer using the game, then wouldn't it just crash?
@xoxogamewolf75859 ай бұрын
nvm i just tested it with wsl and it worked fine
@ZgavY2 жыл бұрын
Okay,but is there a way to make it into an android package instead? Can I port my games to mobile?
@AnoojShete4 жыл бұрын
Hello.. I have a question.. How to shoot bullets in all the direction 360° in mouse pointer like in your aeroblaster game??
@DaFluffyPotato4 жыл бұрын
Watch my video on trig
@AnoojShete4 жыл бұрын
@@DaFluffyPotato okay 👍👍
@Necr0h Жыл бұрын
Thanks for you tuto. But i see to you need to add your Data (with assets, sound, music) with the .Exe to play. Is it possible to compile your code in and executable which includes the assets ? I mean i want to have only one file that secretely contains the assets. To don't let them collectable and modifiable by other users ? Thanks :)
@alexandertownsend50793 ай бұрын
When I try what you did I just an error message telling me that pyinstaller is not a valid internal command. Is it Pyinstaller with a lowercase i or pyInstaller with an uppercase i? Also does pyinstaller have to be in the same folder as my pygame game?
@vamakshi8113 жыл бұрын
Thanks for giving solution for every small problem , subscription is asure from my side
@nerdyturkey3123 жыл бұрын
Cool! Super helpful for my new pygame channel. But my .exe's are kinda massive (200MB) even though only module explicitly imported is pygame 2, and my assets folder is
@DaFluffyPotato3 жыл бұрын
I think it’s including a bunch of unnecessary libraries. If you don’t package as one file, they’re easy to just go and delete. If you want onefile, you’ll need to check the documentation. I don’t have an issue here.
@pratamatanar3 жыл бұрын
thank you so much finally the problem that was making me dizzy was finally solved
@emilis1732 жыл бұрын
thanks, this and some of your other tutorials, super usefull.
@dylanjayabahu28783 жыл бұрын
Is there a way to package all of the images (dependencies) of my program into one so that I don't need to have the file in the same directory as the other images?
@wojtex41193 жыл бұрын
Thank you! Now I can share my games with friends, who don't have python installed.
@naomi28012 жыл бұрын
Hello DaFluffyPotato, thanks for your tutorial. It worked, my issue is that some antivirisus dont like the exe, how did you work around the problem?
@DaFluffyPotato2 жыл бұрын
There are several (not so simple) solutions online. Although if you release a game onto something like Steam where it’s started through a launcher, it’s a non-issue.
@naomi28012 жыл бұрын
@@DaFluffyPotato I tried several, but until now I had no succes. I found a page on stackoverflow the answer was encrypting the code, but that lead to more issues. The other solution was using pyinstaller without --onefile but that is not really what I want. So if you have a solution on hand, I would be grateful.
@technoterminator13682 жыл бұрын
I am having problem is that after writing pyinstaller script name. py then it shows 'tuple index out of range' can you tell how to fix this?
@nikhilhaspe27342 жыл бұрын
thanks dude! i was struggling to convert my game into exe cause i wasn't including assets folder to final exe directory thanks
@keemixvico975 Жыл бұрын
it didn't work as expected... : Traceback (most recent call last): File "menu.py", line 1, in import pygame ModuleNotFoundError: No module named 'pygame'
@anastrong83062 жыл бұрын
Hello! I don't know if you'll answer or even see this comment but i ran into a problem when trying to turn my pygame code into an executable. I followed your steps on installing pyinstaller and moving the data folder to where the executable is. When i try to run it, i get an error saying "no module named pygame". Im positive i have pygame installed because it works fine when i run the code itself. Am i missing something here?
@dhrumildave42212 жыл бұрын
Thx for this, this is so good
@letsgetcopyright26033 жыл бұрын
Best lecture in ever..
@UltronZX Жыл бұрын
this looks helpful but why aren't u running it in python console (and is it possible to do all this in console)?
@JaguarWisdom-9 Жыл бұрын
Thanks, works a treat. Now I can share some mini games. :)
@genericyoutubechanneluwu6 ай бұрын
"alot of people make the mistake of going into build, and looking for the executable," as I'm literally doing that exact thing.
@normalpepsi7993 Жыл бұрын
I have a question, in the code of my game i save the high scores on to a file, but when i make the game an exe it stops saving the high scores do u know how to fix this?
@hey95302 жыл бұрын
dude ur a lifesaver
@jarnedemoen75273 жыл бұрын
Hi! I recently made a simple game and I succesfully converted it to an exe file and my friends can also play it but the only problem is that the movement of my game is a lot slower when I opened the exe file on a friends computer. It's a spaceinvader game and my enemies and spaceship move a lot slower than i had programmed. Do you know what to do about it? Thx in advance :)
@djlazer13 жыл бұрын
Did you add a set FPS, you didn't provide enough information.
@riukywastaken Жыл бұрын
I know it's a bit late, but that seem to be a problem in your code, to avoid that you need to have a setted FPS using the clock function of pygame
@omkakatkar90034 жыл бұрын
Is there a way to create a package of compiled code with all dependencies which needs to be installed once?
@vrajsavani2 жыл бұрын
very usefull! Thank you for this tutorial. 👍
@saturnine.3 жыл бұрын
I'm having an issue where, on running the exe, I get an error that says my engine file couldn't find a file it needs. I have a nearly identical set up with a folder called data with all of assets and engine file in it and it works just fine run in an IDE, but even when the data folder is in the same directory as the exe that pyinstaller creates, I get this error. Any insight would be appreciated
@Samuvt23 жыл бұрын
Does not work, when I open the .exe file it just dont do anything, any fix?
@tunaan80 Жыл бұрын
For me it says it doesn't recognize pyinstaller as a command
@plexus20002 жыл бұрын
It does not work for me when i put in the file that its in it just says cant find path
@Dugiedugdug4 жыл бұрын
Getting a weird error "(1920, 'LoadLibraryExW', 'The file cannot be accessed by the system.')" Firstly I couldnt install python as usual on windows it took me to microsoft store to download it but I found the packages folder in there with pyinstaller.exe. Running it with the path gives the same output as you running "pyinstaller" in CMD so I believe it was opening it correctly. But then it starts to package the .py file and gives this error (among many other outputs)
@jojomark49463 жыл бұрын
I have all the dependencies but when I open the .exe file it closes immediately. help? edit: the problem is C:\Users\MYUSER\PycharmProjects\well\dist>TicTacToe.exe Traceback (most recent call last): File "TicTacToe.py", line 1, in ModuleNotFoundError: No module named 'pygame' [7908] Failed to execute script TicTacToe I have pygame, so I don't get the problem...
@StormwreckerOfficial Жыл бұрын
Hey, man! Thanks for the video! I know you have created multiple games on the market, and I was wondering how you compile all of the different game dependencies (images, sounds, other folders, other python files, etc.) into one file, or at least a folder without hackable files that can be tampered with. I will need help with this in the future, so if you had any thoughts on this, that would be great. Thanks!
@marcus.the.younger4 жыл бұрын
help... newbie programmer here... when i opened the exe file... a command prompt opens up and closes instantly... thanks you for your response in advance
@DaFluffyPotato4 жыл бұрын
Follow the instructions in the pinned comment
@marcus.the.younger4 жыл бұрын
@@DaFluffyPotato will do tnx
@hw20073 жыл бұрын
So..... Windows virus and threat protection keeps auto-deleting the EXE file, because it thinks that it is a virus. Is there any way to stop this?
@DaFluffyPotato3 жыл бұрын
Usually it doesn’t happen if you don’t use -onefile. There are other more tedious methods as well.
@broor3 жыл бұрын
@@DaFluffyPotato it still happens! (btw i love this video it is sublime!)
@JS-fg1kj4 жыл бұрын
thank you for your kind explanation but I have one problem when I use "pygame.font.SysFont" in my script, my exe file execute and close directly when I don't use "pygame.font.SysFont" in my script, my exe file execute sucessfully what should I do if I want to use "pygame.font.SysFont" in my script? p.s. : both cases are executed successfully when using py file
@dafluffypotatovr73624 жыл бұрын
"If you use pygame.font.SysFont(None, x), the executable won't work. You can switch out None for 'calibri' or whatever and it'll work." So just pygame.font.SysFont('calibri',10) or something. I'm not sure what font Pygame uses as None, so you may have to go through a few system fonts.
@JS-fg1kj4 жыл бұрын
@@dafluffypotatovr7362 omg thxxxx it works perfectly
@jarkk08963 жыл бұрын
when i launch the .exe it says: Unhandled exception in script Failed to execute script 'gamename' due to unhandled exception: expected str, bytes or os.PathLike object, not BytesIO Failed to obtain/convert traceback!
@notdouglas19663 жыл бұрын
How do you get around the problem of every anti virus ever thinking the .exe file is a virus or trojan?
@djlazer13 жыл бұрын
You need a software license, which can be expensive. There's no other workarounds.
@notdouglas19663 жыл бұрын
@@djlazer1 ok thx better sell some games ig :/
@mlphyzix Жыл бұрын
Thank you this was very helpful!
@discotrain1732 жыл бұрын
So if I have windows and I want my friend who has a mac to play my game, do I have to package using pyinstaller on a mac to make the executable? Or is there a way I can package my game on my windows operating system for it to work on macs?
@DaFluffyPotato2 жыл бұрын
You have to package it on a mac. I end up not ever porting my games to mac because I don’t have one.
@discotrain1732 жыл бұрын
@@DaFluffyPotato interesting thank you. So when you upload your game on Steam, are you able to send in just your executable with assets/dependencies in a zip folder? Or do you need to do extra steps on your end such as more packaging or coding?
@medveed_ Жыл бұрын
Nuitka: 💀 1 translates code to c 2 nearly impossible to decompile 3 performance boost 4 more compatibility
@thomascasasnovas43724 жыл бұрын
Thanks a lot for this tutorial ! It works fine (:
@MRJakeyBro4 ай бұрын
'Pyinstaller' is not recognized as an internal or external command, operable program or batch file.
@simplepycodes4 жыл бұрын
Is it possible to make a video on how to upload a game made by pygame?
@DaFluffyPotato4 жыл бұрын
You just zip it up and upload it wherever. For Itch.io, it’s super simple and self explanatory. For Steam, it’s more complicated, but I legally can’t because I signed an NDA.
@pihliss Жыл бұрын
I'm new to PyGame. How can I create this "engine.py" file.
@ibritics2 жыл бұрын
Do you have a tutorial of the game that you have developed? It looks so cool!!
@renudixit30874 жыл бұрын
Do i need to add dependencies like os module, pygame module, etc In the same folder , Because i is saying failed to start script
@DaFluffyPotato4 жыл бұрын
Read the pinned comment first since the issue likely isn't what you think. Sometimes PyInstaller has issues with some dependencies, but I've personally never had the issue before and I don't think that's how you deal with it. If it fails to get dependencies, I think there's a way to manually list them for PyInstaller to fetch.
@mahedul4 жыл бұрын
@@DaFluffyPotato The pinned comment is no longer there and I am still facing the same issue please help
@eboatwright_3 жыл бұрын
HELP Edit: I FIXED IT! I just renamed the .exec file to .app, and it works! :D This doesn't work on Mac. It makes the .app file, and a .exec file. The app file doesn't run even with the data folder, but the .exec file does run, but it opens the terminal with it. I have no idea what to do.
@callmeserpent3 жыл бұрын
i have the pyinstaller: error: the following arguments are required: scriptname
@eboatwright_3 жыл бұрын
@@callmeserpent you have to type in pyinstaller then whatever configurations you want.
@paradoxwjs55782 жыл бұрын
what needs to be done to export to mobile?
@tropicomango4 жыл бұрын
help! cannot import name 'opengl_arrays_modules' from 'PyInstaller.utils.hooks' (c:\users\charl\anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py)
@matjeijs32893 жыл бұрын
where do i find the data folder on 5:36?
@prasoonjha18163 жыл бұрын
My dist folder is empty. What should I do?
@lodostic10153 жыл бұрын
Retry and wait for it to complete if u think it wasn't completed I guess
@prasoonjha18163 жыл бұрын
@@lodostic1015 Thanks, but it isn't working I think it's a bug as I am using the latest version of Python and they haven't resolved all bugs in latest version.
@hamzakashif78833 жыл бұрын
Failed to obtain/convert traceback! this is the error i get when i run my exe pls help
@XenolVlatriX3 жыл бұрын
I followed all the steps but I still have the error popup. I cant hear background music from my game but no images..
@DaFluffyPotato3 жыл бұрын
Read the pinned comment
@t8g0 Жыл бұрын
how can i make the exe include the image
@kelsierii47472 жыл бұрын
Hey Im getting an issue where I run the .exe and the console shows up, waits a few seconds, outputs something and immediately closes. I tried running it on cmd and it gives no error. From what I could read the error that shows on the console is about __init__.py and lower down it has something along the lines of "Import error: failed loading dll file: incorrect parameter". I used no flags. edit: ended up using py2exe instead, worked fine and I found no solution at all to my problem with pyinstaller
@DaFluffyPotato2 жыл бұрын
you're gonna have to go down the google rabbit hole for that one. I haven't seen that before (unless it's some sort of audio-related pygame dll, in which case I completely forgot what I had to do).
@kelsierii47472 жыл бұрын
@@DaFluffyPotato ah damn, thanks anyway, maybe something with importing a function from other script. Ill update my comment if I find a solution
@bryankim55954 жыл бұрын
only shows 'C:\Users\teamb\Desktop\PythonWorkspace\pygame_project' is not recognized as an internal or external command, operable program or batch file. when trying to put in directory
@kelsierii47472 жыл бұрын
you have to type cd before that part
@mlungisindlela68102 жыл бұрын
Hi. I'm a huge fan of your work. I don't know if you've considered this, but can you make a phone apk executable from python code? I've been working on my big game and I wanted to make it playable for phone.
@jimmypretzel47853 жыл бұрын
legend thanks for the detailed tutorial!
@IssaalaaRacing3 жыл бұрын
I keep getting fatal error failed to execute file. Why is that?
@DaFluffyPotato3 жыл бұрын
Read the pinned comment
@mdmasudurrahman80744 жыл бұрын
I follow of this steps and able to generate .exe file but after double click the exe it just shoe "Widows has stopped working" please let me know what can I do to resolve this issue.
@DaFluffyPotato4 жыл бұрын
That likely means that your game was stuck in an infinite loop or you weren’t taking input. If you believe there may be an error, follow the instructions in the pinned comment.
@jinwhogames4 жыл бұрын
oh my god thank you so much it help a lot!
@zagaky4 жыл бұрын
Thanks a lot! But how i change the icon of the executable plz
@dafluffypotatovr73624 жыл бұрын
Take a look at this: pyinstaller.readthedocs.io/en/stable/usage.html (--icon)
I have made a simple game using Tkinter and pygame after making them as an executable the tkinter windows works fine but the pygame window opens up and crashes instantly displaying nothing with no error.... I have used only two images in the game and loaded them using pygame.image.load() Any fix for this?
@DaFluffyPotato4 жыл бұрын
Try following the instructions in the pinned comment.
@srich-k4 жыл бұрын
@@DaFluffyPotato it says Failed to execute script pyi_rth_pkgres..... Any solution to this.....I tried out the thing in the pinned comment
@KeiGGR4 жыл бұрын
I'm having a hard time trying to run de .exe. It wasn't working so I ran it throught CMD to see what the error was and I'm getting "pygame Module not found".. I know I can solve this by providing the module path to the interpreter but that would fix it for me, what if anyone else without Python or Pygame wants to use it? Anyone know any more optimal solution? EDIT: nvn fixed it by installing pygame throught CMD (before I installed it throught Pycharm terminal as usual), now is working fine.
@nathnaeldereje5127 Жыл бұрын
Thanks, a lot brother. I've been going through a lot because I couldn't add the assets into the game and my game keeps cruching. Even tried the --add-date but didn't work. Your video though is amaizing.
@succerzxix19504 жыл бұрын
Does the shell not open up when you run the program?
@DaFluffyPotato4 жыл бұрын
The -noconsole line removes it
@penguinmaster65103 жыл бұрын
Can you like do it on a mac?
@myszot68042 жыл бұрын
Thanks for good tutorial!, but allways when i'm trying to open the file, windows defender is popping up and deletes it...
@mahimapandey30822 жыл бұрын
how can i share the exe file. i created a zip of the folder like u have shown in video but idk how to share that zip file with my friends. i cant send on gmail since it doesnt allow sending of exe files even if they are contained inside zip file . i also tried sending by google drive link but whenever my friends try to download the zip it says the file has virus cannot download. plz help 😭😭😭😭😭😭😭😭😭
@CuriousityGaming2 жыл бұрын
Tell your friends to disable the antivirus OR you can also go to settings and make some changes and take permission from the antivirus to run the exe file.
@satwikkar77614 жыл бұрын
thnx bro...i really needed this.,.
@MegaDixen4 жыл бұрын
no idear why but it is not working for me it's make the file and everything it just failed to execute script when i try to run it
@DaFluffyPotato4 жыл бұрын
Read the pinned comment.
@grishakek4 жыл бұрын
I have an issue, it works perfectly but when I want to make the exe file it shows me an error and says "missing module numpy or something..." in my game, I just use pygame and random module, nothing more...
@DaFluffyPotato4 жыл бұрын
Seems odd. One way you could attempt to fix it is to install numpy and import it in your game. It's also possible that you used a function from Pygame that needs numpy (I don't know if any of the functions use it.)
@grishakek4 жыл бұрын
@@DaFluffyPotato thank you for the response, I realized that PyInstaller doesn't support Python 3.8... I installed python 3.7.6 and now it's working. :D
@rinderizard74944 жыл бұрын
Pygame uses numpy in its backend
@aking90774 жыл бұрын
My exe pygame window opens then closes soon after.... No errors when I run it in CMD... If there is an error (from when I used cx Freeze) it says it cant open the images
@DaFluffyPotato4 жыл бұрын
You’re probably not putting the executable in the right directory
@vladimir-sama4 жыл бұрын
Hello, I got an error with tkinter, pygame, and python 3.8 only on pyinstaller. It says pygame.error: Failed loading libmpg123.dll: the specified module could not be found. Thanks for your time.
@DaFluffyPotato4 жыл бұрын
Is that when you run it or when you try to package? If that's during packaging, your Pygame install is likely messed up in some way.
@vladimir-sama4 жыл бұрын
@@DaFluffyPotato its was during run, the fix was copying libmpg123.dll in the same folder as the exe.
@gansless47204 жыл бұрын
@@vladimir-sama same as me, how can i get the libmpg123 file?
@vladimir-sama4 жыл бұрын
@@gansless4720 Find your Python install folder go to lib and site-packages: USER\AppData\Local\Programs\Python\Python38\Lib\site-packages\pygame on windows in my case (Python 3.8 64b
@henrypdt4 жыл бұрын
I had the same problem, I fixed it by converting the music file from mp3 to wav. The pygame.mixer.music.load one.
@yabukichoi91334 жыл бұрын
Newbie question, I'm curious if my pygame can be packed to android and play?
@DaFluffyPotato4 жыл бұрын
I think I’ve heard there are ways to do it, but I haven’t looked into it.
@FeverDev644 жыл бұрын
There is . Its called pygame subset for andriod. You should look it up on youtube.
@adithyadshenoi26684 жыл бұрын
Mine does not open , just puts up a blank screen and goes
@DaFluffyPotato4 жыл бұрын
Did you read the pinned comment? It may help you with your issues.
@alexbaker45113 жыл бұрын
It says failed to obtain/convert traceback
@reanimateddude4324 жыл бұрын
help! when I tried with only --onefile the exe file appears but when I add --noconsole the exe file won't appears
@DaFluffyPotato4 жыл бұрын
So you're saying that there's no error when you package it, but there's also no executable file in dist?
@reanimateddude4324 жыл бұрын
@@DaFluffyPotato thanks for your reply but I sorted out the problem, it was my anti virus that was deleting the runw.exe file assuming it as trojan. So, I allowed it and it made exe file.
@vaibhavkrkm4 жыл бұрын
Nice, by the way, we can convert multiple files package to a setup also by using application like Install Creator!! That's really nice.. Anyways, where did u get Data folder from
@stijndcl2 жыл бұрын
...he made it...? He literally said in the beginning it contains some of the scripts & assets he uses...
@lXBlackWolfXl4 жыл бұрын
I was able to make an executable and it runs fine, but when I exit the game I get an error message pop-up that says "failed to execute script pysnake". My game is a snake clone, obviously. Everything in the game works fine; this pop-up only appears when I trigger my closeGame() function, which happens if I press esc or if I choose to not start another game.
@dafluffypotatovr73624 жыл бұрын
Follow the instructions in the pinned comment. This normally happens when the game encounters an error.
@lXBlackWolfXl4 жыл бұрын
@@dafluffypotatovr7362 The command prompt told me that 'quit' was not defined. My function for closing the game looks like this: def closeGame(): bleep.play() pygame.time.delay(300) pygame.quit() quit() That final command must be what's causing the problem. I have no idea why.
@dafluffypotatovr73624 жыл бұрын
@@lXBlackWolfXl I use sys.exit() (sys needs to be imported though).
@lXBlackWolfXl4 жыл бұрын
@@dafluffypotatovr7362 That fixed the issue, thank you.
@gamert25254 жыл бұрын
How can make exe If my pygame project contain 2-3 files Plz help
@cassette73474 жыл бұрын
Maybe try packing them all into one single file?
@DaFluffyPotato4 жыл бұрын
It's been a while since I recorded this video, but I believe I mentioned that you just put your files in the same folder as the executable PyInstaller outputs. The easy way to get it working is to put the executable in the same directory as the file you turned into the executable.
@beebit_4 жыл бұрын
Hi, nice video! I did what you told me and indeed, it creates an exe file. However, there is an error when I try to open the exe file eventhough my game works when I launch it from Thonny, spyder,etc. Note1 : my images aren't in a separate folder, everything is on the same folder. (Note2 : my python files (.py) are notes by default)
@DaFluffyPotato4 жыл бұрын
You can see the details of the error if you follow the instructions in the pinned comment.
@КостаСтојановић-о8х4 жыл бұрын
Is there a way to change the icon of the .exe file?
@DaFluffyPotato4 жыл бұрын
Yes. For the file, there’s an option in PyInstaller (I don’t remember what it was though). For the taskbar, it’s either determined by Pygame or PyInstaller depending if you’re on Windows or Linux.
@risabhkedia26854 жыл бұрын
I have my game in different python files linked together in a folder. All the images are in the same folder. I copied the exe to that folder and tried to run it but only a black screen appears and dissapears. What do I do??
@dafluffypotatovr73624 жыл бұрын
If a black screen appears and disappears without an error (assuming it's not the command line), it's usually because your script reached the end for some reason. Take a look at the pinned comment if you're having issues.
@risabhkedia26854 жыл бұрын
I tried removing --noconsole and --onefile and ran the executable. The cmd behind showed the typical--"hello welcome to pygame and all that stuff ..."" And then the main screen(still black) appeared and dissapeared without any error. What do I do now??
@risabhkedia26854 жыл бұрын
While I was searching for it I found about environment variables. Should pyinstaller be somehow included in path or something.?
@dafluffypotatovr73624 жыл бұрын
@@risabhkedia2685 It doesn't have to be. It would just change the command you use to package the game. That wouldn't have anything to do with your issue. Like I said the first time though. If it closes like that, check and make sure that it's not running through the whole script. (put a print statement at the beginning and the end then repackage) I don't remember what exactly happens if you use an unnamed system font, so you may want to double check to make sure you aren't doing that. (this was mentioned in the pinned comment)
@risabhkedia26854 жыл бұрын
@@dafluffypotatovr7362 I made all the font names to Arial and the python file works fine the only problem is with the exe. I'll try the print statements and let you know if something goes wrong. Thanks for answering BTW.
@rochakadhikari92644 жыл бұрын
I followed the exact process, but when i try to run the .exe file, it says failed to execute script, i even changed the font in Sysfont to none, but still error popped up
@DaFluffyPotato4 жыл бұрын
You don’t change it to none, you take it out. Also, you can see the error if you follow the instructions in the pinned comment.
@darkvenomz39272 жыл бұрын
It works only when i dont make it noconsole . Can someone help i ca't make it with --noconsole ( i am on Mac)
@glakindustries71634 жыл бұрын
Help me it still gives me an error: Failed to execute script pyi_rth_pkgres what should i do now??
@DaFluffyPotato4 жыл бұрын
Follow the instructions in the pinned comment.
@mega_jc4 жыл бұрын
this might help you, it worked for me: github.com/pyinstaller/pyinstaller/issues/2084