I just checked the wiki and realized you need to input a tonne of code to change a python file containing pygame code to an exe. Is there not an easier way? Shouldn't it just be an exe file that you just open and imput what you want to change and where to save the exe to?
I am not sure I completely understand your question, but I would recommend using PyInstaller. All you have to do it go into the pyinstaller directory, and then run:
python pyinstaller.py /link/to/your/program
which should then make a directory in the pyinstaller directory named after your .py file. In that file you will have a build folder and a dist folder. The dist is the one of interest and will have your .exe in it.
Related
Our Programs is not always a Python source file !.
The Python may be associated with a file or an image,
that is located inside the source of the application to the file path inside the package.
For example, when setting the application icon in Tkinter Or Include image for app background
root.iconbitmap('favicon.ico')
PhotoImage(file = 'python_logo.gif')
In Pyinstaller only the source file expires in the exe format.
If the program contains a file or image path inside the source, then the program will not be executed , In that event,The source of the application and files are in a package (on a route).
Please provide a solution to this problem, So as possible convert a package containing source and file into exe
1-Install cx_Freeze, (open your command prompt and type pip install cx_Freeze
2-Install idna, (open your command prompt and type pip install idna.
3-Write a .py program named myprogram.py
4-Create a new python file named setup.py on the current directory of your script.
5-In the setup.py, code below and save it.
6-With shift pressed right click on the same directory, so you are able to open a command prompt window.
7-In the prompt, type python setup.py build
8-If your script is error free, then there will be no problem on creating application.
9-Check the newly created folder build. It has another folder in it. Within that folder you can find your application. Run it. Make yourself happy.
this works on python 3.5 and above!
Add heres the open source project to convert to exe
https://github.com/brentvollebregt/auto-py-to-exe
I have not used Pyinstaller myself but in cx_Freeze I know you can include none project files like images in the setup file. With Pyinstaller you want to look into the spec file. Here is a link to the docs where it talks about added files to project. https://pythonhosted.org/PyInstaller/spec-files.html#adding-files-to-the-bundle I hope thisis of some help.
Is it possible to repack/rebuild a PyInstaller exe file after extracting the files from it using PyInstaller Extractor? I also decomplied most of the files with Easy Python Decomplier. I modified one .py file and I want the new exe file to contain this modified file. How can I repack the application?
You may leave all not modified files as *.pyc.
Once you have full modules structure ready, just find the original entrypoint and pack the bundle again, it should work.
I am completely new to python and trying to create an application (or .exe) file for python using pyinstaller. I ran the command pyinstaller -[DIRECTORY].py and it saved it to an output directory "C:\Windows\System32\Dist\Foo", however when i tried to locate the directory it did not seem to exist (Dist).
NOTE: i'm trying to convert a .py file to .exe file in Python 3.5
Thanks for any help :)
If you set your command directory to the .py script location and run pyinstaller yourscript.py, it will generate folders in the same location as your script. The folder named dist/ will contain the .exe file.
Could you please try easily the command:
`pyinstaller yourscript.py`
You will get your output folder anyway if everything is correct with your software/module.
Second you can have no rights into System32 folder, so you could try a different folder.
Third you might have inconsistency with the path \ or /.
Hope those three suggestions will lead you to the correct solution :-)
Have a nice day.
I made a program using the pygame module on Python 3 and it works fine within python, but when I try to compile is using py2exe it won't run. (I just get the programName.exe has stopped working error upon trying to run it).
I managed to narrow down this problem to the pygame.font module as when I comment all the lines that use that module everything works fine. I tried to forcefully include the module using the -i flag in py2exe, but it doesn't appear to change anything...
What am I doing terribly wrong?
Edit: I managed to get the reason of the program not working - it crashes as it can not find build\executable.exe\pygame\freesansbold.ttf . What I don't understand is why the hell is the pygame folder supposed to be located in a folder with the name of my executable? (Of course, I can not create a folder with the same name as an existing file in the directory). If anyone has a clue to how to fix it, please help!!
I had the same problem using cx_Freeze, so hopefully this will work for you as well. Open up your pygame package folder. It should be C:\Python34\Lib\site-packages\pygame. There should be a True Type Font File titled freesansbold.ttf. Copy that file then open the folder containing your exe program. There should be a zipped file called library. Open it up and go to the pygame folder inside the zipped file. Should look something like this \build\exe.win32-3.4\library.zip\pygame. And just paste the freesansbold.ttf file in that folder and it should work perfectly.
I managed to find a way! By including -l library.zip argument in the build_exe command and then following the instructions given by DeliriousSyntax in the answer above I managed to get it to work!
I've made my first Python program, using Python 3.2. Now I'm trying to figure out how to make it an executable.
I pretty much only need it for Windows only. I've searched as much as possible and found out that py2exe doesn't support Python 3. cxfreeze does, but I can't figure out how to make a single executable of my program with it. I need it as a portable one-file exe.
Please bear with me as I am a total newcomer :) Any help is appreciated.
You can use cxfreeze to make the executable (and other files it creates), compress them into a *.7z archive using 7-zip, then use 7-ZIP SFX Maker to turn it into a self extracting archive.
When creating the SFX archive, configure it so that the main executable cxfreeze generates runs when the files are extracted. You can also change the archives icon, as well as tell the archive to extract and run from a temporary folder.
When the user runs the exe, the files will extract to the temporary folder and the program will run. To the user, it will behave exactly like a normal exe file.
According to the Python docs, the only program that will package Python3 as an .exe in cx_freeze, and the cx_freeze developer has explicitly stated that he will not support single-file executables (due to the 'dirty hacks' needed, which some anti-malware programs flag as malware).
Comment on the feature request to add Python3 support to py2exe.
You can compare py2exe folder structure with new python3, and make similar. Then you could use SFX idea to store these folders like libraries, python script and interpreter and set script for SFX to just launch your application. As I remember, this is possible in WinRar, and as I think now, in other archivers.