Making an Executable from a Pygame Game (PyInstaller)

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 พ.ย. 2024

ความคิดเห็น •

  • @DaFluffyPotato
    @DaFluffyPotato  4 ปีที่แล้ว +90

    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.

    • @laksanaijampakaew2370
      @laksanaijampakaew2370 4 ปีที่แล้ว +3

      Thanks so much about font

    • @FeverDev64
      @FeverDev64 4 ปีที่แล้ว +3

      Im having issues. The window and console opens and closes after a few seconds

    • @gdsupermoonsuperpresents8404
      @gdsupermoonsuperpresents8404 4 ปีที่แล้ว +5

      It not helped ;-;

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว +1

      @@gdsupermoonsuperpresents8404 did you follow the last step?

    • @gdsupermoonsuperpresents8404
      @gdsupermoonsuperpresents8404 4 ปีที่แล้ว

      @@DaFluffyPotato Ill just making pong, And it have 3 files: ball.py, paddle.py, and main.py, and music

  • @nyct.o
    @nyct.o 4 ปีที่แล้ว +43

    Just wanted to say thanks for your tutorials, they help so much and they're clear and well made

  • @henrypdt
    @henrypdt 4 ปีที่แล้ว +32

    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

    • @stijndcl
      @stijndcl 3 ปีที่แล้ว +2

      @@suvradippaul7843 he literally wrote the solution in the comment

    • @lightpearl1495
      @lightpearl1495 3 ปีที่แล้ว +1

      I wish I could've seen this comment before struggling for a week :/

    • @marcsalvado
      @marcsalvado 2 ปีที่แล้ว +1

      This is the comment I've been looking for

    • @JastaCon
      @JastaCon ปีที่แล้ว

      i have the same problem but my audio-data was wav. from the beginning. so this sadly is no solution to me

  • @seekergx8096
    @seekergx8096 4 ปีที่แล้ว +33

    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

  • @anonyme894
    @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 😍

  • @daboxguy3848
    @daboxguy3848 3 ปีที่แล้ว +3

    I feel like I can't escape your tutorials. This is going to be very useful. Thanks 👍

  • @BattleandForge
    @BattleandForge 3 ปีที่แล้ว +2

    Made an executable from my first game thanks to this tutorial!

  • @medveed_
    @medveed_ ปีที่แล้ว +1

    Nuitka: 💀
    1 translates code to c
    2 nearly impossible to decompile
    3 performance boost
    4 more compatibility

  • @genericyoutubechanneluwu
    @genericyoutubechanneluwu 8 หลายเดือนก่อน +1

    "alot of people make the mistake of going into build, and looking for the executable," as I'm literally doing that exact thing.

  • @vitoroliveira8381
    @vitoroliveira8381 2 ปีที่แล้ว +2

    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!

  • @vamakshi811
    @vamakshi811 4 ปีที่แล้ว

    Thanks for giving solution for every small problem , subscription is asure from my side

  • @pratamatanar
    @pratamatanar 3 ปีที่แล้ว

    thank you so much finally the problem that was making me dizzy was finally solved

  • @anamariabalaban
    @anamariabalaban 2 ปีที่แล้ว +1

    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. 🤗

  • @nikhilhaspe2734
    @nikhilhaspe2734 2 ปีที่แล้ว

    thanks dude!
    i was struggling to convert my game into exe cause
    i wasn't including assets folder to final exe directory
    thanks

  • @letsgetcopyright2603
    @letsgetcopyright2603 3 ปีที่แล้ว

    Best lecture in ever..

  • @wojtex4119
    @wojtex4119 3 ปีที่แล้ว

    Thank you! Now I can share my games with friends, who don't have python installed.

  • @emilis173
    @emilis173 2 ปีที่แล้ว

    thanks, this and some of your other tutorials, super usefull.

  • @JaguarWisdom-9
    @JaguarWisdom-9 ปีที่แล้ว

    Thanks, works a treat. Now I can share some mini games. :)

  • @dhrumildave4221
    @dhrumildave4221 2 ปีที่แล้ว +1

    Thx for this, this is so good

  • @Ravo_Games
    @Ravo_Games 16 ชั่วโมงที่ผ่านมา

    if your getting the error "Pyinstaller is not recognized" use "python -m PyInstaller" instead of PyInstaller, and if you are using an external drive it may not work so use the drive pip installed to

  • @vrajsavani
    @vrajsavani 2 ปีที่แล้ว +1

    very usefull! Thank you for this tutorial. 👍

  • @hey9530
    @hey9530 2 ปีที่แล้ว

    dude ur a lifesaver

  • @sabyasachichoudhury2920
    @sabyasachichoudhury2920 3 ปีที่แล้ว +1

    I'm leaving this comment behind to help anyone who has some of the common errors while converting pygame to exe.
    When converting, the first time do the conversion with the following stuff: pyinstaller whatever_the_man_file_name_is.py --onefile --debug bootloader. After that, run the exe file directly from the command line and not by opening the file. To run it from CMD, just type open CMD in the directory and type in whatever_file_name.exe
    This way, you'll be able to easily see what errors are being generated and then amend them.
    Some common errors:
    - no module named pygame.
    To solve this, just type in pip install pygame. Remember, it has to be installed on your computer as well, not just your IDE.
    - FileNotFoundError: Some dependency is clearly in the correct dictionary, but still returns an error.
    Remove the part from the code which needs the file, create the new exe and run it. Then delete that, add back the parts, and create exe. Should work. Also advise restarting.
    - Sysfont error. It expects some string or bytes, not _bitIO (Or something like that) wrapping.
    That's some intrinsic problem with pygame and pyinstaller. Only way around is use solely Arial or Sans. Sometimes, both work, sometimes only one. Depends on your computer.

  • @rickysacco2720
    @rickysacco2720 4 ปีที่แล้ว +6

    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..?

  • @mlphyzix
    @mlphyzix 2 ปีที่แล้ว

    Thank you this was very helpful!

  • @eboatwright_
    @eboatwright_ 3 ปีที่แล้ว +1

    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.

    • @callmeserpent
      @callmeserpent 3 ปีที่แล้ว

      i have the pyinstaller: error: the following arguments are required: scriptname

    • @eboatwright_
      @eboatwright_ 3 ปีที่แล้ว

      @@callmeserpent you have to type in pyinstaller then whatever configurations you want.

  • @ОбидинНиколай
    @ОбидинНиколай หลายเดือนก่อน +1

    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.

  • @xoxogamewolf7585
    @xoxogamewolf7585 10 หลายเดือนก่อน +1

    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?

    • @xoxogamewolf7585
      @xoxogamewolf7585 10 หลายเดือนก่อน +1

      nvm i just tested it with wsl and it worked fine

  • @frog-animation
    @frog-animation 2 ปีที่แล้ว +1

    Thank you

  • @bovfbovf
    @bovfbovf 3 ปีที่แล้ว +9

    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?

    • @deveagle3608
      @deveagle3608 3 ปีที่แล้ว +1

      I don't know any, other than getting a digital license, but just tell the user to ignore it.

    • @djlazer1
      @djlazer1 3 ปีที่แล้ว +2

      The only way is to get a digital signature which costs money. It kinda sucks but at least they can still run it.

    • @Noober666
      @Noober666 6 หลายเดือนก่อน

      Turn of windows defender and then turn it back on when ur done

  • @valentinvalenciavalencia7299
    @valentinvalenciavalencia7299 2 ปีที่แล้ว

    Thank you very much

  • @thomascasasnovas4372
    @thomascasasnovas4372 4 ปีที่แล้ว +1

    Thanks a lot for this tutorial ! It works fine (:

  • @jinwhogames
    @jinwhogames 4 ปีที่แล้ว +1

    oh my god thank you so much it help a lot!

  • @jimmypretzel4785
    @jimmypretzel4785 4 ปีที่แล้ว

    legend thanks for the detailed tutorial!

  • @satwikkar7761
    @satwikkar7761 4 ปีที่แล้ว

    thnx bro...i really needed this.,.

  • @SamsungGalaxy00176
    @SamsungGalaxy00176 3 ปีที่แล้ว

    thank you bro

  • @Necr0h
    @Necr0h ปีที่แล้ว +1

    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 :)

  • @keemixvico975
    @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'

  • @nathnaeldereje5127
    @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.

  • @dylanjayabahu2878
    @dylanjayabahu2878 4 ปีที่แล้ว +1

    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?

  • @AnoojShete
    @AnoojShete 4 ปีที่แล้ว +1

    Hello..
    I have a question..
    How to shoot bullets in all the direction 360° in mouse pointer like in your aeroblaster game??

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว +1

      Watch my video on trig

    • @AnoojShete
      @AnoojShete 4 ปีที่แล้ว

      @@DaFluffyPotato okay 👍👍

  • @Dorbellprod
    @Dorbellprod 3 ปีที่แล้ว

    Indeed, as some have mentioned, "failed to obtain/convert traceback" has become quite a nuisance, and the closest thing to a playable game in the .EXE format.

  • @ZgavY
    @ZgavY 2 ปีที่แล้ว

    Okay,but is there a way to make it into an android package instead? Can I port my games to mobile?

  • @KeiGGR
    @KeiGGR 4 ปีที่แล้ว +1

    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.

  • @nerdyturkey312
    @nerdyturkey312 3 ปีที่แล้ว +2

    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

    • @DaFluffyPotato
      @DaFluffyPotato  3 ปีที่แล้ว +1

      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.

  • @zagaky
    @zagaky 4 ปีที่แล้ว +2

    Thanks a lot! But how i change the icon of the executable plz

    • @dafluffypotatovr7362
      @dafluffypotatovr7362 4 ปีที่แล้ว

      Take a look at this: pyinstaller.readthedocs.io/en/stable/usage.html (--icon)

    • @Noober666
      @Noober666 6 หลายเดือนก่อน

      exe = EXE(pyz,
      a.scripts,
      [],
      exclude_binaries=True,
      name='YourGame',
      debug=False,
      bootloader_ignore_signals=False,
      strip=False,
      upx=True,
      console=True, icon='icon.ico')

  • @alexandertownsend5079
    @alexandertownsend5079 4 หลายเดือนก่อน

    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?

  • @omkakatkar9003
    @omkakatkar9003 4 ปีที่แล้ว

    Is there a way to create a package of compiled code with all dependencies which needs to be installed once?

  • @naomi2801
    @naomi2801 2 ปีที่แล้ว +1

    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?

    • @DaFluffyPotato
      @DaFluffyPotato  2 ปีที่แล้ว

      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.

    • @naomi2801
      @naomi2801 2 ปีที่แล้ว

      ​@@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.

  • @jojomark4946
    @jojomark4946 3 ปีที่แล้ว

    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...

  • @Dugiedugdug
    @Dugiedugdug 4 ปีที่แล้ว

    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)

  • @jarkk0896
    @jarkk0896 3 ปีที่แล้ว

    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!

  • @notdouglas1966
    @notdouglas1966 3 ปีที่แล้ว +1

    How do you get around the problem of every anti virus ever thinking the .exe file is a virus or trojan?

    • @djlazer1
      @djlazer1 3 ปีที่แล้ว

      You need a software license, which can be expensive. There's no other workarounds.

    • @notdouglas1966
      @notdouglas1966 3 ปีที่แล้ว

      @@djlazer1 ok thx better sell some games ig :/

  • @matjeijs3289
    @matjeijs3289 3 ปีที่แล้ว

    where do i find the data folder on 5:36?

  • @MRJakeyBro
    @MRJakeyBro 5 หลายเดือนก่อน

    'Pyinstaller' is not recognized as an internal or external command,
    operable program or batch file.

  • @paradoxwjs5578
    @paradoxwjs5578 2 ปีที่แล้ว

    what needs to be done to export to mobile?

  • @adithyadshenoi2668
    @adithyadshenoi2668 4 ปีที่แล้ว +1

    Mine does not open , just puts up a blank screen and goes

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      Did you read the pinned comment? It may help you with your issues.

  • @kaan_tuna
    @kaan_tuna ปีที่แล้ว

    For me it says it doesn't recognize pyinstaller as a command

  • @tropicomango
    @tropicomango 4 ปีที่แล้ว

    help!
    cannot import name 'opengl_arrays_modules' from 'PyInstaller.utils.hooks' (c:\users\charl\anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py)

  • @pihliss
    @pihliss ปีที่แล้ว

    I'm new to PyGame. How can I create this "engine.py" file.

  • @marcus.the.younger
    @marcus.the.younger 4 ปีที่แล้ว +1

    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

  • @bryankim5595
    @bryankim5595 4 ปีที่แล้ว

    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

    • @kelsierii4747
      @kelsierii4747 2 ปีที่แล้ว

      you have to type cd before that part

  • @technoterminator1368
    @technoterminator1368 2 ปีที่แล้ว

    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?

  • @XenolVlatriX
    @XenolVlatriX 3 ปีที่แล้ว

    I followed all the steps but I still have the error popup. I cant hear background music from my game but no images..

  • @samoht8916
    @samoht8916 5 หลายเดือนก่อน

    thanks

  • @myszot6804
    @myszot6804 2 ปีที่แล้ว

    Thanks for good tutorial!, but allways when i'm trying to open the file, windows defender is popping up and deletes it...

  • @QUASAR098
    @QUASAR098 3 ปีที่แล้ว +3

    get an executable with one simple trick! windows HATES this executable!
    memes aside windows really thinks my exe file has Wacatac!B in it ...

  • @saturnine.
    @saturnine. 4 ปีที่แล้ว

    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

  • @normalpepsi7993
    @normalpepsi7993 2 ปีที่แล้ว

    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?

  • @ibritics
    @ibritics 3 ปีที่แล้ว

    Do you have a tutorial of the game that you have developed? It looks so cool!!

  • @plexus2000
    @plexus2000 2 ปีที่แล้ว

    It does not work for me when i put in the file that its in it just says cant find path

  • @beebit_
    @beebit_ 4 ปีที่แล้ว +2

    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)

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว +1

      You can see the details of the error if you follow the instructions in the pinned comment.

  • @JS-fg1kj
    @JS-fg1kj 4 ปีที่แล้ว +1

    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

    • @dafluffypotatovr7362
      @dafluffypotatovr7362 4 ปีที่แล้ว +1

      "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-fg1kj
      @JS-fg1kj 4 ปีที่แล้ว +1

      @@dafluffypotatovr7362 omg thxxxx it works perfectly

  • @Samuvt2
    @Samuvt2 3 ปีที่แล้ว

    Does not work, when I open the .exe file it just dont do anything, any fix?

  • @anastrong8306
    @anastrong8306 2 ปีที่แล้ว

    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?

  • @simplepycodes
    @simplepycodes 4 ปีที่แล้ว +1

    Is it possible to make a video on how to upload a game made by pygame?

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      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.

  • @jarnedemoen7527
    @jarnedemoen7527 3 ปีที่แล้ว +2

    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 :)

    • @djlazer1
      @djlazer1 3 ปีที่แล้ว +2

      Did you add a set FPS, you didn't provide enough information.

    • @riukywastaken
      @riukywastaken ปีที่แล้ว +1

      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

  • @renudixit3087
    @renudixit3087 4 ปีที่แล้ว +1

    Do i need to add dependencies like os module, pygame module, etc
    In the same folder ,
    Because i is saying failed to start script

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      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.

    • @mahedul
      @mahedul 4 ปีที่แล้ว

      @@DaFluffyPotato The pinned comment is no longer there and I am still facing the same issue please help

  • @UltronZX
    @UltronZX ปีที่แล้ว

    this looks helpful but why aren't u running it in python console (and is it possible to do all this in console)?

  • @hey9530
    @hey9530 2 ปีที่แล้ว

    it works, but the video is not so clear

  • @StormwreckerOfficial
    @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!

  • @succerzxix1950
    @succerzxix1950 4 ปีที่แล้ว

    Does the shell not open up when you run the program?

  • @discotrain173
    @discotrain173 2 ปีที่แล้ว

    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?

    • @DaFluffyPotato
      @DaFluffyPotato  2 ปีที่แล้ว

      You have to package it on a mac. I end up not ever porting my games to mac because I don’t have one.

    • @discotrain173
      @discotrain173 2 ปีที่แล้ว

      @@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?

  • @penguinmaster6510
    @penguinmaster6510 3 ปีที่แล้ว

    Can you like do it on a mac?

  • @Lucas264
    @Lucas264 4 ปีที่แล้ว +1

    Thank you so much!! It works 100% fine except I get the error at 3:59 when I try to put everything in a "data" folder right next to the .exe

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      It doesn’t have to be a data folder. You basically just replace your main script with the packaged one.

    • @Lucas264
      @Lucas264 4 ปีที่แล้ว

      Hmm... so far every time I put the assets into a different folder as the .exe file (like you did) they were off limits to the program. The packaged script is the .exe, right? Or am I missing something...

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      The packaged script is the exe. Try dropping it in the same folder you work in (along with the script you packaged). Although if you happen to be on Mac OS, then it may not work due to working directory issues.

    • @anto-s8x
      @anto-s8x 3 ปีที่แล้ว

      @@Lucas264 When you move the assets to a separate folder you need to specify the directory in the python script. Before you didn't need to do this as they were on the same folder as the python file, but now they are in another directory.
      Example (Windows): pygame.image.load("data\whatever.png")
      Example (Linux and Mac): pygame.image.load("data/whatever.png")

  • @ishankamboj3522
    @ishankamboj3522 4 ปีที่แล้ว +1

    My .exe file shows an error that it had stopped working. Pls help

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      Does the screen turn white? This can happen when you aren’t taking user input or the game is in an infinite loop. Also, I’d recommend reading the pinned comment and following the instructions there to check for errors.

    • @ishankamboj3522
      @ishankamboj3522 4 ปีที่แล้ว

      Thank you sir

  • @dakshgarg775
    @dakshgarg775 4 ปีที่แล้ว +1

    Plz someone tell how to hide the console from exe file

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      Use the -noconsole argument

    • @dakshgarg775
      @dakshgarg775 4 ปีที่แล้ว

      @@DaFluffyPotato Thanks for telling

  • @КостаСтојановић-о8х
    @КостаСтојановић-о8х 4 ปีที่แล้ว

    Is there a way to change the icon of the .exe file?

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      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.

  • @theonlydhruv7888
    @theonlydhruv7888 2 ปีที่แล้ว

    when I try to to do this(I'm on Mac btw) it works... but when I try to open it, the pygame window opens and closes after a second. This also happens when I put in all the data

  • @mdmasudurrahman8074
    @mdmasudurrahman8074 4 ปีที่แล้ว

    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.

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      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.

  • @aking9077
    @aking9077 4 ปีที่แล้ว

    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

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      You’re probably not putting the executable in the right directory

  • @kelsierii4747
    @kelsierii4747 2 ปีที่แล้ว

    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

    • @DaFluffyPotato
      @DaFluffyPotato  2 ปีที่แล้ว +1

      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).

    • @kelsierii4747
      @kelsierii4747 2 ปีที่แล้ว

      @@DaFluffyPotato ah damn, thanks anyway, maybe something with importing a function from other script. Ill update my comment if I find a solution

  • @advaitshrivastava6119
    @advaitshrivastava6119 4 ปีที่แล้ว

    My .exe file is not running. When I click, it just shows a blank black window for a few second and then it terminates.
    Please help me.

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว +1

      Follow the instructions in the pinned comment

    • @advaitshrivastava6119
      @advaitshrivastava6119 4 ปีที่แล้ว

      @@DaFluffyPotato Okay so when I changed the SysFont to Font it is working, thank you so much.
      But when I close the .exe after the execution of the program I get an error window, failed to execute the script. How to overcome that?

  • @hw2007
    @hw2007 3 ปีที่แล้ว

    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?

    • @DaFluffyPotato
      @DaFluffyPotato  3 ปีที่แล้ว +1

      Usually it doesn’t happen if you don’t use -onefile. There are other more tedious methods as well.

    • @broor
      @broor 3 ปีที่แล้ว

      @@DaFluffyPotato it still happens! (btw i love this video it is sublime!)

  • @darkvenomz3927
    @darkvenomz3927 2 ปีที่แล้ว

    It works only when i dont make it noconsole . Can someone help i ca't make it with --noconsole ( i am on Mac)

  • @grishakek
    @grishakek 4 ปีที่แล้ว

    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...

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว +1

      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.)

    • @grishakek
      @grishakek 4 ปีที่แล้ว

      @@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

    • @rinderizard7494
      @rinderizard7494 4 ปีที่แล้ว

      Pygame uses numpy in its backend

  • @gargoyled_drake
    @gargoyled_drake 2 ปีที่แล้ว

    maybe another way is possible, since doing it like this will flag your game executable as malware/trojan/virus for every single antivirus out there and there for not be doing anything good for anyone, except now those that follows this have pyinstaller on their system while being positive that it's not something that they should have installed to begin with.

  • @rochakadhikari9264
    @rochakadhikari9264 4 ปีที่แล้ว

    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

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      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.

  • @lXBlackWolfXl
    @lXBlackWolfXl 4 ปีที่แล้ว

    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.

    • @dafluffypotatovr7362
      @dafluffypotatovr7362 4 ปีที่แล้ว

      Follow the instructions in the pinned comment. This normally happens when the game encounters an error.

    • @lXBlackWolfXl
      @lXBlackWolfXl 4 ปีที่แล้ว +1

      @@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.

    • @dafluffypotatovr7362
      @dafluffypotatovr7362 4 ปีที่แล้ว +1

      ​@@lXBlackWolfXl I use sys.exit() (sys needs to be imported though).

    • @lXBlackWolfXl
      @lXBlackWolfXl 4 ปีที่แล้ว

      @@dafluffypotatovr7362 That fixed the issue, thank you.

  • @vladimir-sama
    @vladimir-sama 4 ปีที่แล้ว

    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.

    • @DaFluffyPotato
      @DaFluffyPotato  4 ปีที่แล้ว

      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-sama
      @vladimir-sama 4 ปีที่แล้ว

      @@DaFluffyPotato its was during run, the fix was copying libmpg123.dll in the same folder as the exe.

    • @gansless4720
      @gansless4720 4 ปีที่แล้ว

      @@vladimir-sama same as me, how can i get the libmpg123 file?

    • @vladimir-sama
      @vladimir-sama 4 ปีที่แล้ว

      @@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

    • @henrypdt
      @henrypdt 4 ปีที่แล้ว

      I had the same problem, I fixed it by converting the music file from mp3 to wav. The pygame.mixer.music.load one.