I am looking for a way to convert a Python Program to a .exe file WITHOUT using py2exe. py2exe says it requires Python 2.6, which is outdated. Is there a way this is possible so I can distribute my Python program without the end-user having to install Python?
-
3[According to this](http://www.py2exe.org/index.cgi/Tutorial#Step52) py2exe can support 2.6, 2.7, 3.0, 3.1 as long as you can supply the MSVCR90.dll – Michael Berkowski May 15 '12 at 01:07
-
2I've used py2exe with 2.7.2 and 2.7.3. – wkl May 15 '12 at 01:08
-
4I cannot comment, but I need to alert people of this due to security reasons. Virus Total flags PyInstaller with 7 different viruses, and the checksums do not match. **DO NOT DOWNLOAD AS OF 22:56 -5:00GMT ON SEPTEMBER 21, 2016.** I had to post this because it is recommended in several answers, including the chosen one. I just found this question and answer while searching, and almost used PyInstaller as recommended before realizing that I should probably scan it first. I'm glad I took those precautions. – John Lardinois Sep 22 '16 at 03:59
9 Answers
Understand that every 'freezing' application for Python will not really secure your code in any way. Every packaging system for a stand-alone executable Python 'program' will include a lot of the Python libraries and interpreter, which will make your program pretty large.
That said, PyInstaller has done a nearly flawless job with everything I've thrown at it. Currently it only supports up to Python 2.7 but Pyinstaller's support for a varied set of libraries large and small is unmatched in other 'freeze' type programs for Python.

- 8,514
- 6
- 43
- 69

- 4,335
- 1
- 26
- 37
-
this seems like it will work just fine. But i am slightly confused on how to set it up. Is there a link you can give me or some simple instructions? thank you for this @PenguinCoder and all you others who answerd my question – bolharr2250 May 15 '12 at 19:59
-
@bolharr2250 [StackOverflow](http://stackoverflow.com/questions/5543920/comprehensive-tutorial-on-pyinstaller) question for "Pyinstaller tutorial"! The [Pyinstaller manual](http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html?format=raw#getting-started) on getting started , is the best place to start. – PenguinCoder May 15 '12 at 20:04
I use cx_Freeze. Works with Python 2 and 3, and I have tested it to work on Windows, Mac, and Linux.
cx_Freeze: http://cx-freeze.sourceforge.net/

- 123
- 2
- 6
some people talk very well about PyInstaller

- 4,387
- 2
- 22
- 35
-
I also tried to convert a python (2.7.3) project with many 3rd Part libs to an executable with py2exe, but it didn t work! Than i tried pyinstaller (which takes more efford to install) and everything work like a charm! – user1911091 Jan 29 '14 at 22:52
If it is a simple py script refer here
Else for GUI :
$ pip3 install cx_Freeze
1) Create a setup.py file and put in the same directory as of the .py file you want to convert.
2)Copy paste the following lines in the setup.py and do change the "filename.py" into the filename you specified.
from cx_Freeze import setup, Executable
setup(
name="GUI PROGRAM",
version="0.1",
description="MyEXE",
executables=[Executable("filename.py", base="Win32GUI")],
)
3) Run the setup.py "$python setup.py build"
4)A new directory will be there there called "build". Inside it you will get your .exe file to be ready to launced directly. (Make sure you copy paste the images files and other external files into the build directory)
py2exe works with Python 2.7 (as well as other versions). You just need the MSVCR90.dll

- 49,085
- 60
- 166
- 233
I've used py2exe in the past and have been very happy with it. I didn't particularly enjoy using cx-freeze as much, though

- 110,290
- 27
- 149
- 241
For this you have two choices:
- A downgrade to python 2.6. This is generally undesirable because it is backtracking and may nullify a small portion of your scripts
- Your second option is to use some form of
exe
converter. I recommendpyinstaller
as it seems to have the best results.

- 1
- 1

- 11
- 1
There is another way to convert Python scripts to .exe files. You can compile Python programs into C++ programs, which can be natively compiled just like any other C++ program.

- 30,230
- 67
- 195
- 328