0

I am a beginner at python programming and I am facing a minor issue. I created a pygame called "Dino Rush" which works perfectly on PyCharm.

I used pyinstaller to convert my .py file to .exe file. I followed all the steps mentioned in this video.

https://youtu.be/UZX5kH72Yx4

Please have a look at this video and tell me why it won't work for me.

By following these steps, an executable file is created but it gives the error "Failed to execute script dino_rush ".

PS If it helps, I use python version 3.8, PyCharm version 2019.3 Community edition, pip version 20.0.2 and i have imported the following modules in my code : pygame, random, math, os.

If you don't find this method good enough, then please suggest any other method to help me in converting my file to .exe. I am just a beginner and I would appreciate any kind of help.

Adit
  • 13
  • 3
  • you may want to look into cx_freeze rather than pyinstaller. https://cx-freeze.readthedocs.io/en/latest/ – Alex Jadczak Apr 06 '20 at 19:58
  • Thank you for suggesting cx_Freeze. I was able to create an exe file which worked but the images and audio files were still not IN that exe file (they were still separate from the exe). Do you think compressing that entire folder now with the exe, images and audio into zip file and then converting that into exe with some third party app would work? Or any other way you know? – Adit Apr 07 '20 at 09:47
  • cx_Freeze doesn't try to make a single file executable like pyinstaller does. Instead it's going to compile your python code into an executable and then copy the needed libraries and link against them so your code can run without needing a python environment on the target machine. Packaging files into a single executable is not a common practice (check out programs in your "C:\Program Files" directory). If you are looking for an installer for your program, you can use the bdist_msi options in cx_freeze. – Alex Jadczak Apr 11 '20 at 01:50

1 Answers1

0

Hey for the images you can convert them to Base64 and use them or there is another trick I discovered and EZ get the binary or the hex of your files and store them in a variable like this

Png_Picture = "0063006f002e006c0069006e0064006f
002e006e006f002d0065006d00750000
00000000003900000031535053b1166d
44ad8d7048a748402ea43d788c1d0000
00680000000048000000522ba7fdde39
2d499539dac989e5e106000000000000
000000000000"

and save it to your file in the Temp folder and get your images path Use this thread if you don't know how to save your String(that contains the hex) as a hex file

Warning: Better not to download the pictures from any external source or save the files with extension .exe because AV may detect it as a Dropper