Python programming-Converting a Python program into an executable program [organizing]_python

Source: Internet
Author: User
Tags bz2 win32 in python
工欲善其事, its prerequisite. Python is an interpreted language, but it's too cumbersome to add a python shell to execute a program under Windows. And here's what it means to convert a Python program to an EXE file. Here are some common tools , but it seems that py2exe is more widely used.
Py2exe http://py2exe.sf.net
Only support Windows platform, it should be the most people heard a name, a lot of users, so there are problems in its mail list is easy to find the answer. The document mentions "can't find So-and-so code", using modules such as OpenGL
 

Pypackage http://codereactor.net/projects/pypack/index.html
I think py2exe and so on tools or wordy like Tang monk, need to write in the configuration file required data files. The author completely ignores the fact that I need to publish the executable, the program is finished, all the data files are in the main directory, so in most cases, there is no need to search elsewhere. Now that someone has finally stood up, Pypackage is not really a program-packaged tool, but simply simplifies py2exe operations, and can even automatically invoke Innosetup 5 to make installation files--but the software is not intelligent, it packs a lot of unwanted files.
 

Installer http://www.mcmillan-inc.com/installer_dnld.html
You can generate executable files for Windows, Linux platforms, and now the author's homepage is not connected, but a search can be downloaded elsewhere
With a small program to write a configuration file, if the program is more complex, or need to manually modify this profile. Support for all Python versions since py15
September 2005, Frozen Oyster update: Giovanni Bajo obtained Gordon McMillan ' s installer authorization, copyright change to GPL, and in http://pyinstaller.hpcf.upr.edu/ Continue to develop Pyinstaller. September 2006 Update: Here you can see the image of the original site of Gordon McMillan ' s
 

Python's own freeze.py (although the Windows version does not have this, you can download the Python source program yourself and then find it). This is one of the least recommended methods for me (why?) See for yourself), but if your Python program is going to be published on a platform that other tools don't support, consider this approach
 

The new Pyco http://www.pythonapocrypha.com/projects/pyco/.
It's not working.
 

Squeeze http://starship.python.net/crew/fredrik/ipa/squeeze.htm
It's not used, it only supports Python 1.4.
 

Cx_freeze http://starship.python.net/crew/atuining/cx_Freeze/
Winodws, Linux platform. Simple programs don't even need to write a configuration file
 

Stand alone Python for Windows http://arctrix.com/nas/python/standalone.html
If you don't mind that the source program is too "exposed," use this.
Will it feel like Updated:sun, April 2000 18:39:54-0600? If you look at its VC source code, you will not think so-actually this is universally applicable to the win system, whether 98, 2000 or XP. It may also be used on Linux-I do not know Linux, if you really can do so, please tell me.
 

Py2app http://undefined.org/python/
Tools that support the Linux platform may also support Mac OS, or use this py2app directly. I don't know, I've only eaten apples, I haven't played Apple before.
 

Movable Python http://www.voidspace.org.uk/python/movpy/
This is actually the use of py2exe made, can be placed on a USB disk on the green Python. There are plans to use Py2app to make an Apple version movpy and to make a Linux version movpy with Cx_freeze. People who are too lazy to learn py2exe, Py2app, or cx_freeze can look at them.
 

Shed Skin-a python-to-c++ Compiler: Pilot project, Windows, even his example I did not compile successfully:(.
 

Psyco: Something that accelerates a Python program does not see the direct benefit of releasing a Python program, and the author will later commit to PyPy.
 

PyPy: The project goal is Python implemented in pure Python, faster than CPython, and can help build Python in the future.
 

Pyc:python compiler in Python, a python-bytecode compiler written in pure Python, can optimize the output of PYC files. As with PyPy, there's no immediate benefit to publishing Python programs. Only Py24 's bytecode. PYC is part of the new Python virtual machine PYVM.
 

Jungle: Use the GNU tools (as, LD, and Winres) to compile a Python program into a Windows EXE executable file. The executable file uses only Python24-based Pythonic.dll. Guess the modules it supports are limited to internal modules as well as modules listed by JUNGLE.JGL. Only the executable file is downloaded, and the executable file is compiled with jungle itself. The current version number is 1.10, often see the version number of 0.xx, this number is very big ah, Wahaha.
 

Alternative methods, the Python language features are not 100% support, a large number of CPython modules can not be used, and, I have not tried:


For. NET Python compiler (such as Visual Python, IronPython), but I don't like to install the. NET Framework for a sesame-heavy software.

Use Jython, then wrap it in JBuilder, Jsmooth, Nativej, or compile the cost code with GCJ
In the end, give a person learn Py2exe article, help to learn:

Recently learned a little python, want to write a Python program to the exe file, found in the Internet to find the material after this Dongdong
Write it down and do the recording.

English Course:
Http://www.py2exe.org/index.cgi/Tutorial


Python 2.5 + Py2exe

Working directory: C:\python25


First, write a random program.
hello.py

Print "Hello world!"


Test to see if you can run
Python hello.py
Result: Hello World

Download Py2exe to www.py2exe.org, or load it up in SF
http://sourceforge.net/project/showfiles.php?group_id=15583

Next, install the Py2exe package directly. It is an installation file. Just put it on the line.

Under write a settings for the py file setup.py

From Distutils.core Import Setup
Import Py2exe
Setup (console=[' hello.py '])


Running: Python setup.py py2exe
After the following information appears, in the Dist directory, there will be a hello.exe
is success.

Running Py2exe
Searching for Required modules * * *
Parsing Results * * *
Creating python loader for extension ' zlib '
Creating python loader for extension ' unicodedata '
Creating python loader for extension ' bz2 '
Finding DLLs Needed * * *
Create binaries * * *
byte compile python files * * * *
Byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\bz2.py to Bz2.pyc
Byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\unicodedata.py to Unicodedata.pyc
Byte-compiling C:\Tutorial\build\bdist.win32\winexe\temp\zlib.py to Zlib.pyc
Skipping byte-compilation of c:\Python24\lib\StringIO.py to Stringio.pyc

[Skipping many lines for brevity]

Skipping byte-compilation of c:\Python24\lib\warnings.py to Warnings.pyc
Copy Extensions * * *
Copy DLLs * * *
Copying C:\Python24\lib\site-packages\py2exe\run.exe-> C:\Tutorial\dist\hello.exe

Binary Dependencies * * *
Your executable (s) also depend on these DLLs which are not included,
You or May is not need to distribute them.

Make sure your have the license if you distribute any of them, and
Make sure you don ' t distribute files belonging to the operating system.

Advapi32.dll-c:\windows\system32\advapi32.dll
User32.dll-c:\windows\system32\user32.dll
Shell32.dll-c:\windows\system32\shell32.dll
Kernel32.dll-c:\windows\system32\kernel32.dll

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.