Python programming-translating Python programs into executables [grooming]
Source: Internet
Author: User
工欲善其事, its prerequisite. Python is an interpreted language, but it's too troublesome to add a python shell if you want to execute a program under Windows. And here's what this is about is converting the 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 the Windows platform, should be the most people hear a name, a lot of users, so there is a problem in its mail list is easy to find the answer. The document mentions "can't find a Code" and uses modules such as OpenGL.
Pypackage http://codereactor.net/projects/pypack/index.html
I think py2exe and so on tools still wordy like Tang's monk, need to write in the configuration file required data files. The author completely ignores the fact that when I need to publish the executable, the program is finished, and all the data files are in the directory where the main program is located, so in most cases there is no other place to search. Now someone has finally stood up, Pypackage is actually not a program packaging tools, but simply to simplify the py2exe operation, and even can automatically call Innosetup 5 production installation files--but this software is not smart, will pack a lot of unnecessary files
Installer http://www.mcmillan-inc.com/installer_dnld.html
Can produce the Windows, Linux platform executable files, now the author home page is not even up, but search can be downloaded elsewhere
Bring a small program to write the configuration file, if the program is more complex, still need to manually modify the configuration file. Support for all Python versions since py15
September 2005, Frozen Oyster update: Giovanni Bajo obtained Gordon McMillan's installer authorization, copyright changed to GPL, and in http://pyinstaller.hpcf.upr.edu/ Continue to develop Pyinstaller. September 2006 Update: Here you can see the image of Gordon McMillan ' s original website
Python comes with the freeze.py (although the Windows version does not have this, you can download the Python source program to find it yourself). This is one of my least recommended methods (why?) See it yourself), but if your Python program is going to be published on a platform that is not supported by other tools, consider this method
The new Pyco http://www.pythonapocrypha.com/projects/pyco/.
It didn't work.
Squeeze http://starship.python.net/crew/fredrik/ipa/squeeze.htm
It's not working, only Python 1.4 is supported.
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 if the source program is too "exposed," use this.
Will you feel Updated:sun, 2000 18:39:54-0600? If you look at its VC source code, you will not think so-in fact, this is generally applicable to the win system method, whether it is 98, 2000 or XP. Maybe it can also be used on Linux-I don't know Linux, and if I can do this, please let me know.
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 apples yet.
Movable Python http://www.voidspace.org.uk/python/movpy/
This is actually a green python made with py2exe that can be placed on a USB stick. There are plans to use Py2app to make Apple version movpy and to make Linux version movpy with Cx_freeze. People who are too lazy to learn py2exe, Py2app or cx_freeze can look at it.
Shed Skin-a python-to-c++ Compiler: Pilot project, on Windows, even his example I did not compile successfully:(.
Psyco: Something that accelerates the Python program does not see the immediate benefit of publishing a Python program, and the author will be committed to PyPy later.
PyPy: The goal of the project is to implement Python in pure Python, faster than CPython, and in the future can help with compiling python.
Pyc:python compiler in Python, a python bytecode compiler written in pure python, optimizes the output of PYC files. As with PyPy, there is no immediate benefit to publishing a Python program. Only Py24 's bytecode. PYC is part of the PYVM new Python virtual machine.
Jungle: Use the GNU tool (as, LD, and Winres) to compile the Python program into the Windows EXE executable file. The executable file uses only Python24-based Pythonic.dll. Guess the modules it supports are limited to internal modules and the modules listed in JUNGLE.JGL. Only executable files are downloaded, and the executable is compiled with jungle itself. The current version number to 1.10, often look at the 0.xx version number, this number is very big ah, Wahaha.
Alternative approach, the Python language features are not 100% support, a lot of cpython modules can not be used, and I have not tried:
For. NET Python compilers (such as Visual Python, IronPython), but I don't like to install the. NET Framework for a sesame-big software
Use Jython, then wrap it with JBuilder, Jsmooth, Nativej, or compile the cost code with GCJ
At the end, give a person learning Py2exe articles to help with learning:
Recently learned a little python, want to translate the Python program into EXE file, found the information on the Internet after the discovery of this stuff
Write it down and make a note.
English Course:
Http://www.py2exe.org/index.cgi/Tutorial
Python 2.5 + Py2exe
Working directory: C:\python25
First, write a program.
hello.py
Print "Hello world!"
Test if you can run
Python hello.py
Result: Hello World
Download the Py2exe to www.py2exe.org, or load it on 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 in writing a set of py files setup.py
From Distutils.core Import Setup
Import Py2exe
Setup (console=[' hello.py ')
Run: Python setup.py py2exe
After the following information appears, in the Dist directory, there will be a hello.exe
is successful.
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 is not included,
Need to distribute them.
Make sure your license if you distribute any of them, and
Make sure you don ' t distribute files belonging to the operating system.
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