Тёмный

Convert Python Files To EXE using PyInstaller | PyGame Tutorial 

Coding With Russ
Подписаться 49 тыс.
Просмотров 85 тыс.
50% 1

In this video I will explain how to package your python files into an executable so you can easily distribute them. I will be using pyinstaller for this and will show a few useful settings that make the process easier.
If you come across an error that says: "Pip is not recognised as an internal or external command" then check out this link for solutions:
stackoverflow.com/questions/2...
Check out my other PyGame tutorials:
Space Invaders coding tutorial: • Pygame Space Invaders ...
Flappy Bird coding tutorial: • PyGame Flappy Bird Beg...

Опубликовано:

 

4 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 156   
@khalilebdelli6199
@khalilebdelli6199 8 месяцев назад
after days and days of trying to debug the problem, i finally came across your video , can't thank you enough , you're literally helping me pay my rent. thank you
@CodingWithRuss
@CodingWithRuss 8 месяцев назад
Glad I could help :)
@ScherzoVivo
@ScherzoVivo 2 года назад
Ha, I just finished your shooter tutorial and went to another tab of RU-vid just to search for a video like this. Without really reading the author, "Oh this one looks promising!" And suddenly it's the voice I just finished listening to. Imagine that lol!
@CodingWithRuss
@CodingWithRuss 2 года назад
Haha, good old youtube algorithm!
@ScherzoVivo
@ScherzoVivo 2 года назад
@@CodingWithRuss It knows which ones the *quality* videos are! ^.^
@MaxerDev
@MaxerDev Год назад
Thanks so much for this! You went in depth perfectly with all of the errors and perfectly explained how to fix them
@CodingWithRuss
@CodingWithRuss Год назад
Thanks! Glad it helped.
@baibhabchakraborty821
@baibhabchakraborty821 Год назад
Love your way of teaching and guiding, man!
@CodingWithRuss
@CodingWithRuss Год назад
Thank you!
@fidel2xl
@fidel2xl 2 года назад
Another very helpful vid, and also thanks again for the quick response, Russ. Btw, are these instructions applicable to Macs as well? Or it doesn't matter --- it works for same for both Macs and Windows? Thanks.
@kennethpascasio5701
@kennethpascasio5701 6 месяцев назад
Thank you Russ!!! My first script has been processed to an executable now.
@joshr3079
@joshr3079 Год назад
This guy and his videos DOMINATE
@CodingWithRuss
@CodingWithRuss Год назад
Thanks :)
@star_t1
@star_t1 2 года назад
Exactly I was looking for. Now I can make apps using python. Thanks!
@CodingWithRuss
@CodingWithRuss 2 года назад
Glad I could help!
@spoopy870
@spoopy870 Год назад
i have been trying to use pyinstaller for like a year straight for this shitty space invaders clone i made and this is the only video that has explained it properly
@CodingWithRuss
@CodingWithRuss Год назад
Nice, glad it helped
@ZacLangston
@ZacLangston 2 года назад
yes i was one of the people that suggested this video idea!
@kashifumer8755
@kashifumer8755 10 месяцев назад
Does not seem to work on mac if there are other .png files (like the ones you have shown in the example above). Have you tried on mac? Thanks
@famaral42
@famaral42 10 месяцев назад
Very helpful, thx! Doubt: The sample game that I used to taste this had the __file__ dir path to get the images. I had to get rid of that and use relative import. Is that the correct way to do it?
@Pizza_Gamer_Guy
@Pizza_Gamer_Guy 4 месяца назад
You are a lifesaver! Thank you!
@Litfield
@Litfield Год назад
typical pyinstaller' is not recognized as an internal or external command, operable program or batch file.
@MonaLisa.mp4
@MonaLisa.mp4 6 месяцев назад
im having the same issure
@ImpossibleEvan
@ImpossibleEvan 3 месяца назад
You probably already found the solution since it has been a year but for anyone reading this replace the command with "python -m PyInstaller script.py" instead
@sylentnova
@sylentnova 3 месяца назад
For anyone, like me, looking in the comments for an *easy* solution to this: - Find out where pyinstaller is installed. It should say when you install it. For me it was a long path that ended with Python312\Scripts - Move pyinstaller.exe to the same folder as the scripting you're trying to export - Try running the command again Online there was a lot of mumbo jumbo about path variables or something I didn't understand. But this worked for me
@torki3439
@torki3439 14 дней назад
@@sylentnovait workssss
@SmoothBurger
@SmoothBurger Год назад
I dont know why, but when i type pyinstaller it comes with an error, I do have it installed and i do have a python file. Is this because my game does not the pygame extention or because of a new release of pip??
@bullitttraders4995
@bullitttraders4995 Год назад
Hello can you help, when i run the "pyinstaller platformer --onefile --windowed" i get a UPX is not available.
@dustin0001
@dustin0001 10 месяцев назад
Real-time antivirus protections blocks this file from being created as it thinks it contains a virus. Is there a way around this other than simply disabling anti-virus?
@garrettwill1220
@garrettwill1220 3 месяца назад
i have a small app. I want to know if there is a way to essentially include the assets within the executable file?
@bengeorge92
@bengeorge92 11 месяцев назад
Could we bundle the images into the executable itself by using the pyinstaller flag for data?
@zialielmahdy
@zialielmahdy Год назад
Thank you for sharing
@Shoeb._.248G
@Shoeb._.248G 5 месяцев назад
Thank you for clarifiying my issue!!!
@CodingWithRuss
@CodingWithRuss 5 месяцев назад
Glad it helped!
@keemixvico975
@keemixvico975 9 месяцев назад
I use conda environment because I have so many packages like Langchain or other...and it don't work...How can I do ?
@user-lo1bd8yc3q
@user-lo1bd8yc3q 7 месяцев назад
I would like to ask you what we should do, if we want to access all of our projects in PyCharm on another device after we have installed Windows 11 for example - is it an option to convert all python files into to EXE, put it on a USB and then plug it into the new device?
@perspectiva5952
@perspectiva5952 7 месяцев назад
bro you are a genius!
@danielbarlev1849
@danielbarlev1849 Год назад
you are my savior! Thank you!!!
@CodingWithRuss
@CodingWithRuss Год назад
Glad it helped!
@JuggernautVault
@JuggernautVault Год назад
failed to execute script 'game' due to unhandled exception: expected str, bytes or os.Pathlikeobject, not BytesIO failed to obtain/convert traceback!
@causeandconsequences
@causeandconsequences 8 месяцев назад
I'm trying to change the folder my strip is located. How do we do this? Thanks in advance!
@adamaitlahcen5169
@adamaitlahcen5169 Год назад
Hey thanks for the tutorial but whenever I do exactly what you did it shows "permission denied" any solution please
@khargos7602
@khargos7602 4 месяца назад
Holy moly adjusting the PATH to get the pyinstaller command working took some thought. I wonder why it ended up where it did.
@anushiyaarjunan4455
@anushiyaarjunan4455 10 месяцев назад
Thanks you so much ...perfectly working
@CodingWithRuss
@CodingWithRuss 10 месяцев назад
Glad to hear it
@lolhahalaughlaugh8033
@lolhahalaughlaugh8033 3 месяца назад
im making a game engne built on pygame, this is really useful, im gonna try make a python or batch file to automate this
@deetonmahalik8401
@deetonmahalik8401 11 месяцев назад
Pyinstaller in not recognised, plz help on this error
@Qq-wk8mg
@Qq-wk8mg 4 месяца назад
i get the error message "pygame.error: video system not initialized", but the code runs fine, what do I do
@warbuld1085
@warbuld1085 Год назад
that's really helpful
@CodingWithRuss
@CodingWithRuss Год назад
Thanks
@Martyfarty293
@Martyfarty293 5 месяцев назад
when i do windowed it says this app cannot run on your pc im using windows 11 if that does anything
@spiderbite7849
@spiderbite7849 8 месяцев назад
Does a method exist for storing images inside of .exe files?
@wee8149
@wee8149 4 месяца назад
Thank u sir, this helped me alot! Is there a more performant way to create an exe? It takes much time until the exe is started...
@agreeddig2312
@agreeddig2312 Год назад
Wow it works ty
@jaredhasdf7499
@jaredhasdf7499 Год назад
Even after I’ve opened the command line from within the file & and download pyinstaller it tells me pyinstaller isn’t recognized as a internal or external command. Any help for this?
@_brawler
@_brawler Год назад
check ur "pyinstaller" spelling it happened to me too and tht was because i spelled it wrong
@amateruss
@amateruss Год назад
Didn't know I had a coding channel.
@sujeethakula8591
@sujeethakula8591 Год назад
im having trouble converting.The executable file is doing nothing.PLs help
@sampyuays
@sampyuays Месяц назад
do you have to install it every time?
@user-wz5qc3vu6o
@user-wz5qc3vu6o 6 месяцев назад
thank you so mucch
@ghulamhussain2780
@ghulamhussain2780 Год назад
When I open exe file it just opens for a while as black screen and then disappeares. Please help me!!!!
@esther6664
@esther6664 Год назад
hello thanks for the tutorial. however i have an error zhen i want to launcher the .exe file I use a module named wxglade it's a module that help make a graphic interface to my game(i made a launcher zith game in them) and i can't find how to fix it anywhere. some help would be awesome
@CodingWithRuss
@CodingWithRuss Год назад
Hi Esther, I've never used that module before so I'm not familiar with the issues that result in making that into an .exe
@plexus2000
@plexus2000 2 года назад
Ok so I have been trying to do this with the platformer game that you did I finished through all 13 videos and when I tried to run the EXE it still popped up but then closed shortly after any help?
@CodingWithRuss
@CodingWithRuss 2 года назад
That's strange, I used the platformer as an example in this vid and it works fine for me. Did you try it with the --windowed flag?
@plexus2000
@plexus2000 2 года назад
@@CodingWithRuss yes
@user-jt7rj3rb7x
@user-jt7rj3rb7x 2 года назад
I have the same, was able to solve this problem?
@skycloud4802
@skycloud4802 Год назад
Has anyone had any luck getting their Steam Deck to play their packaged Pygame games? I managed to package my pygame game and it runs on windows on my pc so I know there's no errors. I successfully ran a python shell packaged game and it actually works on Steam Deck. So I finally tried my Pygame on the Steam Deck. It managed to unpack or install it. But it doesn't play, it closes straight away. I tried Proton experimental but that doesn't work either. Anyone got ideas?
@yvngkuba
@yvngkuba Год назад
I dont have "pip" command in my cmd. Why?
@Thrawien
@Thrawien Год назад
I get an error stating Traceback (most recent call last): File "main.py", line 1, in import pygame, sys, random, button ModuleNotFoundError: No module named 'pygame' im not sure how to correct this. Does anyone have any advice?
@CodingWithRuss
@CodingWithRuss Год назад
It means you don't have pygame installed. I have a video on getting started with pygame that explains how to get it setup here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-y9VG3Pztok8.html
@netstormuk
@netstormuk 6 месяцев назад
Thanks, wonder why the exe still opens a cmd in the background, was hoping creating this exe would not requre the cmd to be open.
@astelthyninja8927
@astelthyninja8927 4 месяца назад
--noconsole is the flag to stop the cmd from opening
@keepbryan6697
@keepbryan6697 Год назад
thanks. however, i'm looking for a way which 1 exe file can include all assets (images, sound...). could you help me?
@thinkingspace3438
@thinkingspace3438 Год назад
if your project is big it's better to use an archive file (.zip or something more obfuscated like .pak) along with the exe, otherwise there's options in pyinstaller to include files but you have to adapt the code to load the assets, and you can still extract them with 7zip very easily an other obscure way is to make a code file that loads the assets as byte data, if you use an encryption key in pyinstaller the assets will not easily be extractible at all, but don't do this if you have too much assets
@thinkingspace3438
@thinkingspace3438 Год назад
also, sound files are generaly big and should be streamed instead of being loaded into ram, so if you use them in the exe or in an archive file, be sure to make a copy of them somewhere in appdata and remove them when you leave the game. i'm not sure of how engines like unity do the trick but it's probably something like this
@adroklop
@adroklop 5 месяцев назад
pls help ('pyinstaller' is not recognized as an internal or external command, operable program or batch file.)
@adroklop
@adroklop 5 месяцев назад
i did pip install pyinstaller
@thanujankyt7278
@thanujankyt7278 2 года назад
script 'C:\Users\Tj\platformer.py' not found
@ItsQuazey
@ItsQuazey 5 месяцев назад
it says pyinstalle is allready installed and then i do the next command it says pyinstaller is not recognised
@it.is.i.KRISHNA
@it.is.i.KRISHNA 29 дней назад
Can we do it in a phone?
@YouTuber_J23
@YouTuber_J23 8 месяцев назад
God bless you
@b-sync-research-lab
@b-sync-research-lab 10 месяцев назад
for me it says pyinstaller is not a command or some thing
@chikkii1601
@chikkii1601 2 года назад
First like 🥳🥳🥳🥳🥳🥳🥳
@maxmuster7003
@maxmuster7003 8 месяцев назад
I like to make a batch file with all commands to create an exe file from a tiny python script with the name test.py. Please add the commands. @echo off pip?
@Twilight0D
@Twilight0D 10 месяцев назад
Amazing
@CodingWithRuss
@CodingWithRuss 10 месяцев назад
Thanks!
@ggrolton123
@ggrolton123 9 месяцев назад
'pyinstaller' is not recognized as an internal or external command, operable program or batch file.
@sim-on3187
@sim-on3187 Год назад
I get the error import pygame no module namend 'pygame'
@adroklop
@adroklop 5 месяцев назад
do 'pip install pygame' in the python terminal OR in cmd
@Beaullay
@Beaullay 2 года назад
pyinstaller : The term 'pyinstaller' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. im getting this error and cant fix it ._.
@strxben
@strxben 2 года назад
did u figure it out?
@andrev4822
@andrev4822 Год назад
@Coding With Russ
@andrev4822
@andrev4822 Год назад
@Coding With Russ
@user-ce5kn2cs1r
@user-ce5kn2cs1r 7 месяцев назад
'pyinstaller' is not recognized as an internal or external command, operable program or batch file. i got this error, article did not resolve it for me so im stuck..
@CodingWithRuss
@CodingWithRuss 7 месяцев назад
Check out this short video to get you setup: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-0x_MEKr0OJQ.html
@ADudeNamedSol
@ADudeNamedSol 7 месяцев назад
Thank you for the tutorial! But I was just wondering, If I send it to a friend does he need to have python installed on his PC?
@CodingWithRuss
@CodingWithRuss 7 месяцев назад
No, once you have converted it to an exe they will be able to run that file without python as long as you send them all the associated files and assets
@ADudeNamedSol
@ADudeNamedSol 7 месяцев назад
@@CodingWithRuss Okay, Thanks! You helped me alot
@adilivni8688
@adilivni8688 6 месяцев назад
I did what you show on the video but nothing succied
@obvVexi
@obvVexi Год назад
When i try to "pip install pyinstaller" it says that isn't recognised as a internal or external command
@CodingWithRuss
@CodingWithRuss Год назад
It may be that you don't have pip added to PATH on your pc. I don't have a tutorial on this but if you google adding pip to PATH, you will find instructions to help
@shinyduck5324
@shinyduck5324 2 года назад
ty
@CodingWithRuss
@CodingWithRuss 2 года назад
You're welcome!
@shreyasTechy
@shreyasTechy 5 месяцев назад
Perfect!... I have one doubt here. If you want to share this exe file to someone.. You need to give all other files too right.?- In this scenario, you just having some png's. thats not a big deal. if you share... Coming to my scenario, I have multiple py's that interlinked and one is main file. Once I convert main.py to main.exe., If i keep in this directory then exe will work. If I want to share to my team members, I can't share other py's files. Bcoz if i share they can view the code and modifies too. I need to share only one .exe file. What's solution for this? Thank you in advance.
@SkyFly19853
@SkyFly19853 2 года назад
Very useful. ✅ Btw, is there a way to obfuscate the exe file? Like a video game on a CD?
@CodingWithRuss
@CodingWithRuss 2 года назад
Good question, I've never looked into it properly as all my projects have been open source so I can't help with that one! I know pyinstaller has a "key" flag to encrypt the code, so may be something to look into: pyinstaller.readthedocs.io/en/stable/usage.html#cmdoption-key but there are probably more secure ways depending on how far you want to go.
@SkyFly19853
@SkyFly19853 2 года назад
@@CodingWithRuss I understand what you mean. Thank you very much for giving the link. I can also use that one.
@thinkingspace3438
@thinkingspace3438 Год назад
video games on CD (like the ones for consoles) are not windows executables, if you're talking about windows games installers they generaly have everything in a .bin file that is used to extract the stuff and install it on your device
@SkyFly19853
@SkyFly19853 Год назад
@@thinkingspace3438 I see... 🤔
@mhf_98
@mhf_98 11 месяцев назад
the problem on my program says "Nomodule named pygame". what is the solution?
@CodingWithRuss
@CodingWithRuss 11 месяцев назад
I have a video that covers that error: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-0x_MEKr0OJQ.html
@mhf_98
@mhf_98 11 месяцев назад
@@CodingWithRuss thank you!
@mavkarmahmut5768
@mavkarmahmut5768 Год назад
ModuleNotFoundError: No module named 'pygame' help me plz
@Jassimathgenius
@Jassimathgenius 2 месяца назад
just do 'pip install pygame'
@BaconBuildsYT
@BaconBuildsYT 2 месяца назад
it delets my exe whean i did the windowed
@vegasdealer777
@vegasdealer777 10 месяцев назад
Thanks for doing the video! When I run the EXE in my main folder, Windows 10 says, "This app can't run on your PC." I tried 'run as administrator.' No luck with that, either. App runs fine under Python, though.
@maxmuster7003
@maxmuster7003 8 месяцев назад
Maybe the script need special commands inside to run as an exe file?
@vegasdealer777
@vegasdealer777 8 месяцев назад
@@maxmuster7003 -- Thanks -- What I had to do was copy my /pix folder with all the images into the DIST folder. I guess I thought the images would be embedded in the EXE.
@maxmuster7003
@maxmuster7003 8 месяцев назад
@@vegasdealer777 I like the idea to load image files from an exe file on runtime and let the images outside, so we can easy change the image without to compile the exe file again for changing images.
@vegasdealer777
@vegasdealer777 8 месяцев назад
@@maxmuster7003 Thanks for the comment. I see what you mean!
@chikkii1601
@chikkii1601 2 года назад
First comment 🥳🥳🥳🥳🥳🥳🥳
@CodingWithRuss
@CodingWithRuss 2 года назад
:)
@alonepoptart24_6
@alonepoptart24_6 4 месяца назад
it doesnt recognize pygame as a module pls help it works fine in vsc
@ksfq
@ksfq 3 месяца назад
yeah same it says pygame is missing
@Mr_Tutorial_Master
@Mr_Tutorial_Master 3 месяца назад
you need to select the right path for pygame
@alonepoptart24_6
@alonepoptart24_6 3 месяца назад
@@Mr_Tutorial_Master i fixed i (installed pygame wrong)
@dhruvitpatel3827
@dhruvitpatel3827 4 месяца назад
hi want help
@jamesclive2452
@jamesclive2452 6 месяцев назад
f it doesnt work recognise your command run "python -m PyInstaller script.py --onefile"
@asjg007
@asjg007 2 года назад
@Coding with Russ Hey Russ. Could you make a similar video on how to convert PyGame Python file (your game for example) into APK for Android?
@CodingWithRuss
@CodingWithRuss 2 года назад
Hi, that's not something I've ever tried, so I'm not sure, sorry!
@OfficalOxy
@OfficalOxy Год назад
it did not recongnize pyinstaller as a command but it recongnized pip
@CodingWithRuss
@CodingWithRuss Год назад
If pip is working then you can type "pip install pyinstaller" into your command prompt, which will download it for you
@TestSubject-ik4oq
@TestSubject-ik4oq 6 месяцев назад
i get pyinstaller is not reconized
@CodingWithRuss
@CodingWithRuss 6 месяцев назад
Make sure it is installed with "pip install pyinstaller"
@TestSubject-ik4oq
@TestSubject-ik4oq 6 месяцев назад
I did that and it didnt work , i fixed it by downgrading python to older version @@CodingWithRuss
@user-kh5gs7rs2m
@user-kh5gs7rs2m Год назад
Просто лучший!!!
@Gamingman12362
@Gamingman12362 5 месяцев назад
This for some reason gave me a trojan horse virus i took care of it but wtf
@LucasGamerEpik53
@LucasGamerEpik53 4 месяца назад
this dont work, pyinstaller aint recongized
@asifzaman678
@asifzaman678 Год назад
Need microscope to see
@gustavorosas-dev
@gustavorosas-dev 10 месяцев назад
Muito obrigado, funcionou!
@tristandombroski9677
@tristandombroski9677 Год назад
I had a problem where I opened up everything like you showed but it says cannot find my .py file. C:\Users\trist\Desktop\SlimeRanger>pyinstaller Slime.py --onefile 386 INFO: PyInstaller: 5.7.0 386 INFO: Python: 3.11.1 398 INFO: Platform: Windows-10-10.0.19045-SP0 399 INFO: wrote C:\Users\trist\Desktop\SlimeRanger\Slime.spec 403 INFO: UPX is not available. script 'C:\Users\trist\Desktop\SlimeRanger\Slime.py' not found C:\Users\trist\Desktop\SlimeRanger> but it updated my folder directory with a build, dist and spec file although they are all empty
@CodingWithRuss
@CodingWithRuss Год назад
Hmm I haven't seen that one before although googling "UPX is not available" brought up a few posts so have a look and see if any of those fixes apply.
@tristandombroski9677
@tristandombroski9677 Год назад
@@CodingWithRuss I got it to work by using the auto-py-to-exe application that I had to download using the pip3 installer... Man, it took me a minute but I finally got it. While I have you're attention, when you have the basic outline of a game established like the video you have "The Complete Introduction to Pygame" what do you start working on first? more collision events and swing animations with weapons and/or opening up player movement or environment map? A thought on the matter would be nice. Lastly thank you for getting back to my first comment. Happy new year.
@CodingWithRuss
@CodingWithRuss Год назад
@@tristandombroski9677 Ah good that you got it working in the end, shame pyinstaller didn't seem to work though. I don't have hard and fast rules and it depends on the game but typically I will move onto creating a character, adding in controls and then working on collision. If I am using a tile map then I would load that in next and make sure the tile collision is working. Then animations etc. So the core mechanics first and then make the game look nice after. Happy new year to you too.
@user-jt7rj3rb7x
@user-jt7rj3rb7x 2 года назад
i have this error: File "game.py", line 1, in ModuleNotFoundError: No module named 'pygame'
@CodingWithRuss
@CodingWithRuss 2 года назад
You would need to install pygame first, check out pygame.org for the install instructions
@Jesterthe
@Jesterthe 11 месяцев назад
And what if you have multiple PYthon files?
@FredSoft
@FredSoft 2 месяца назад
'pip' is not recognized as an internal or external command, operable program or batch file.
@andrev4822
@andrev4822 Год назад
'pyinstaller' is not recognized as an internal or external command, operable program or batch file.
@Nalix_68
@Nalix_68 Год назад
i get it too
@andrev4822
@andrev4822 Год назад
@@Nalix_68 I fixed u have to download a different version of it
@Nalix_68
@Nalix_68 Год назад
@andrev4822 thx but i alredy fixed it
@skroogemcducc
@skroogemcducc Год назад
@@andrev4822 what version and how do i download that version. I'm getting same error.
Далее
How to Create a Menu in Pygame
15:29
Просмотров 108 тыс.
C++ Developer Learns Python
9:26
Просмотров 2,7 млн
Making an Executable from a Pygame Game (PyInstaller)
6:08
Why The Windows Phone Failed
24:08
Просмотров 199 тыс.
Python py to exe 🏃
3:43
Просмотров 85 тыс.
Convert Python To Exe Files
8:20
Просмотров 69 тыс.
2 YEARS of PYTHON Game Development in 5 Minutes!
4:54
Просмотров 885 тыс.