When we write a python file, we can use command line “python test.py” to execute this file, but we need python environment, when publish programs, most user don’t have python in their PC, so sometimes we need to transfer python to executable file, like exe.   Here are two methods to make it. Suppose our code like below: #encoding:utf-8 #test.py if __name__ == "__main__": print("Hello world!")   1. py2exe project link: http://sourceforge.net/projects/py2exe/ latest version just support python 2.6 Install py2exe Create a python file named setup.py, code is: #encoding=utf-8 # test.py from distutils.core import setup import py2exe setup(console=["test.py"]) then execute in command: python setup.py py2exe It will generate a dir named dist, dir dist include test.exe, python26.dll,library.zip, etc.   2.python.cx_freeze project link: http://sourceforge.net/projects/cx-freeze/ support python version 2.x 3.x install it Create a python file named setup.py, code is: # encoding:utf-8……

阅读全文