Python(wiki en chs)是一门弱类型解释型脚本语言,拥有动态类型系统和垃圾回收功能,支持多种编程范式:面向对象、命令式、函数式和过程式编程。
由于Python拥有一个巨大而广泛的标准库,这使得Python功能十分强大,开发者在标准库提供的基础上能快速完成想要的功能。
Python在所有操作系统上实现了解释器,这使得Python可以跨平台运行于不同操作系统之上。
Python有2个版本:Python2(2000.10.16发布)和Python3(2008.12.3发布)。
Python3不完全兼容Python2。不过由于Python2使用广泛,后来很多Python3新特性也被移植到旧的Python2.6/2.7版本上。
如:在Python2中,print是一个关键字;而Python3中,print是一个函数。
适用于Python3以上版本以及Python2.6/2.7
print("Hello, world!")
适用于Python2.6以下版本以及Python2.6/2.7
print "Hello, world!"
然而,Python脚本需安装Python环境才能被解释执行,为了使开发出的Python脚本在所有的机器上运行,我们可以使用py2exe来发行我们的Python脚本。
py2exe可以把Python脚本转换成windows下的exe可执行程序(即不需安装Python)。
Python2.7(32位)请下载安装:py2exe-0.6.9.win32-py2.7.exe
Python2.7(64位)请下载安装:py2exe-0.6.9.win64-py2.7.amd64.exe
下载其他Python2对应的py2exe版本请访问:https://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/
Python3.3/3.4(32位)请下载安装:py2exe-0.9.2.2.win32.exe
Python3.3/3.4(64位)请下载安装:py2exe-0.9.2.2.win-amd64.exe
注:py2exe不支持最新Python3.6(原因是Python3.6采用了新的字节码格式)
由于我的本机开发环境是Python2.7(32位),因此安装对应的安装包是py2exe-0.6.9.win32-py2.7.exe
安装完成后,py2exe会向E:\Python27目录中拷贝如下文件和目录
注1:py2exe-wininst.log为安装日志,记录详细的安装过程
注2:Removepy2exe.exe为卸载程序,执行E:\Python27\Removepy2exe.exe -u "E:\Python27\py2exe-wininst.log"卸载py2exe
py2exe主要实现如下功能:
① 编译Python标准库成字节码,并打包到library.zip压缩包中
② 拷贝Python相关的运行时库
③ 转换Python脚本成exe可执行文件
④ 拷贝相关的资源文件
下文以CalcMD5.py为例,说明py2exe转换过程:
1. Python2.7(32位)环境下使用vscode编写的CalcMD5.py
#!/usr/bin/env python #coding=utf-8 import BaseLib if __name__ == '__main__': BaseLib.PrintHello()
BaseLib.py的内容如下:
#!/usr/bin/env python #coding=utf-8 def PrintHello(): print "Hello"
2. 编写py2exe转换脚本setup.py(放在CalcMD5.py同一目录)
from distutils.core import setup import py2exe setup(console=["CalcMD5.py"])
更多setup.py配置用法说明:
① 上述 setup.py 中指定产生一个 console 程序; 若要产生一个有 windows 窗口的程序,将 "console" 改成 "windows":
setup(windows=["CalcMD5.py"])
② 若要生成多个可执行文件,只要将多个python文件名以 list 方式传给 setup() 即可:
setup(console=["CalcMD5.py", "other1.py", "other2.py"])
③ 也可以同时产生 console 和 windows 程序:
setup(console=["CalcMD5.py", "other1.py"], windows=["other2.py"])
④ 应用程序有时需要使用到一些外部文件,例如字体或是图片等, 通过setup()的data_files参数,可以将这些额外的文件加入发布目录中。
将一个或多个 (目的目录, [源文件1,源文件2...源文件n]) 形成的 tuple,包装成 list 指派给 data_files参数即可:
setup(console=["CalcMD5.py", "other1.py"], windows=["other2.py"], data_files=[("img",[r"d:\documents\pic1.jpg",r"d:\documents\pic2.jpg"]), ("xml",[r"e:\config.xml"])] )
最后产生的dist目录中,应该会有一个img目录,内含 pic1.jpg 和 pic2.jpg 两个文件,以及 xml 目录,内含一个 config.xml 文件。
⑤ 更多setup.py的语法请参考py2exe的例子 Lib\site-packages\py2exe\samples
3. 在CalcMD5.py目录下,执行以下命令进行转换
E:\Python27\python.exe setup.py py2exe
生成转换日志如下:
running py2exe creating I:\Test\PythonTest\PyPrj1\build creating I:\Test\PythonTest\PyPrj1\build\bdist.win32 creating I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe creating I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\collect-2.7 creating I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\bundle-2.7 creating I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\temp creating I:\Test\PythonTest\PyPrj1\dist *** searching for required modules *** *** parsing results *** creating python loader for extension 'unicodedata' (e:\Python27\DLLs\unicodedata.pyd -> unicodedata.pyd) creating python loader for extension 'select' (e:\Python27\DLLs\select.pyd -> select.pyd) creating python loader for extension '_hashlib' (e:\Python27\DLLs\_hashlib.pyd -> _hashlib.pyd) creating python loader for extension 'bz2' (e:\Python27\DLLs\bz2.pyd -> bz2.pyd) *** finding dlls needed *** *** create binaries *** *** byte compile python files *** byte-compiling I:\Test\PythonTest\PyPrj1\BaseLib.py to BaseLib.pyc byte-compiling I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\temp\_hashlib.py to _hashlib.pyc byte-compiling I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\temp\bz2.py to bz2.pyc byte-compiling I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\temp\select.py to select.pyc byte-compiling I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\temp\unicodedata.py to unicodedata.pyc byte-compiling e:\Python27\lib\StringIO.py to StringIO.pyc byte-compiling e:\Python27\lib\UserDict.py to UserDict.pyc byte-compiling e:\Python27\lib\__future__.py to __future__.pyc byte-compiling e:\Python27\lib\_abcoll.py to _abcoll.pyc byte-compiling e:\Python27\lib\_strptime.py to _strptime.pyc byte-compiling e:\Python27\lib\_threading_local.py to _threading_local.pyc byte-compiling e:\Python27\lib\_weakrefset.py to _weakrefset.pyc byte-compiling e:\Python27\lib\abc.py to abc.pyc byte-compiling e:\Python27\lib\atexit.py to atexit.pyc byte-compiling e:\Python27\lib\base64.py to base64.pyc byte-compiling e:\Python27\lib\bdb.py to bdb.pyc byte-compiling e:\Python27\lib\calendar.py to calendar.pyc byte-compiling e:\Python27\lib\cmd.py to cmd.pyc byte-compiling e:\Python27\lib\codecs.py to codecs.pyc byte-compiling e:\Python27\lib\collections.py to collections.pyc byte-compiling e:\Python27\lib\copy.py to copy.pyc byte-compiling e:\Python27\lib\copy_reg.py to copy_reg.pyc byte-compiling e:\Python27\lib\difflib.py to difflib.pyc byte-compiling e:\Python27\lib\dis.py to dis.pyc byte-compiling e:\Python27\lib\doctest.py to doctest.pyc byte-compiling e:\Python27\lib\dummy_thread.py to dummy_thread.pyc byte-compiling e:\Python27\lib\encodings\__init__.py to encodings\__init__.pyc creating I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\collect-2.7\encodings byte-compiling e:\Python27\lib\encodings\aliases.py to encodings\aliases.pyc byte-compiling e:\Python27\lib\encodings\ascii.py to encodings\ascii.pyc byte-compiling e:\Python27\lib\encodings\base64_codec.py to encodings\base64_codec.pyc byte-compiling e:\Python27\lib\encodings\big5.py to encodings\big5.pyc byte-compiling e:\Python27\lib\encodings\big5hkscs.py to encodings\big5hkscs.pyc byte-compiling e:\Python27\lib\encodings\bz2_codec.py to encodings\bz2_codec.pyc byte-compiling e:\Python27\lib\encodings\charmap.py to encodings\charmap.pyc byte-compiling e:\Python27\lib\encodings\cp037.py to encodings\cp037.pyc byte-compiling e:\Python27\lib\encodings\cp1006.py to encodings\cp1006.pyc byte-compiling e:\Python27\lib\encodings\cp1026.py to encodings\cp1026.pyc byte-compiling e:\Python27\lib\encodings\cp1140.py to encodings\cp1140.pyc byte-compiling e:\Python27\lib\encodings\cp1250.py to encodings\cp1250.pyc byte-compiling e:\Python27\lib\encodings\cp1251.py to encodings\cp1251.pyc byte-compiling e:\Python27\lib\encodings\cp1252.py to encodings\cp1252.pyc byte-compiling e:\Python27\lib\encodings\cp1253.py to encodings\cp1253.pyc byte-compiling e:\Python27\lib\encodings\cp1254.py to encodings\cp1254.pyc byte-compiling e:\Python27\lib\encodings\cp1255.py to encodings\cp1255.pyc byte-compiling e:\Python27\lib\encodings\cp1256.py to encodings\cp1256.pyc byte-compiling e:\Python27\lib\encodings\cp1257.py to encodings\cp1257.pyc byte-compiling e:\Python27\lib\encodings\cp1258.py to encodings\cp1258.pyc byte-compiling e:\Python27\lib\encodings\cp424.py to encodings\cp424.pyc byte-compiling e:\Python27\lib\encodings\cp437.py to encodings\cp437.pyc byte-compiling e:\Python27\lib\encodings\cp500.py to encodings\cp500.pyc byte-compiling e:\Python27\lib\encodings\cp720.py to encodings\cp720.pyc byte-compiling e:\Python27\lib\encodings\cp737.py to encodings\cp737.pyc byte-compiling e:\Python27\lib\encodings\cp775.py to encodings\cp775.pyc byte-compiling e:\Python27\lib\encodings\cp850.py to encodings\cp850.pyc byte-compiling e:\Python27\lib\encodings\cp852.py to encodings\cp852.pyc byte-compiling e:\Python27\lib\encodings\cp855.py to encodings\cp855.pyc byte-compiling e:\Python27\lib\encodings\cp856.py to encodings\cp856.pyc byte-compiling e:\Python27\lib\encodings\cp857.py to encodings\cp857.pyc byte-compiling e:\Python27\lib\encodings\cp858.py to encodings\cp858.pyc byte-compiling e:\Python27\lib\encodings\cp860.py to encodings\cp860.pyc byte-compiling e:\Python27\lib\encodings\cp861.py to encodings\cp861.pyc byte-compiling e:\Python27\lib\encodings\cp862.py to encodings\cp862.pyc byte-compiling e:\Python27\lib\encodings\cp863.py to encodings\cp863.pyc byte-compiling e:\Python27\lib\encodings\cp864.py to encodings\cp864.pyc byte-compiling e:\Python27\lib\encodings\cp865.py to encodings\cp865.pyc byte-compiling e:\Python27\lib\encodings\cp866.py to encodings\cp866.pyc byte-compiling e:\Python27\lib\encodings\cp869.py to encodings\cp869.pyc byte-compiling e:\Python27\lib\encodings\cp874.py to encodings\cp874.pyc byte-compiling e:\Python27\lib\encodings\cp875.py to encodings\cp875.pyc byte-compiling e:\Python27\lib\encodings\cp932.py to encodings\cp932.pyc byte-compiling e:\Python27\lib\encodings\cp949.py to encodings\cp949.pyc byte-compiling e:\Python27\lib\encodings\cp950.py to encodings\cp950.pyc byte-compiling e:\Python27\lib\encodings\euc_jis_2004.py to encodings\euc_jis_2004.pyc byte-compiling e:\Python27\lib\encodings\euc_jisx0213.py to encodings\euc_jisx0213.pyc byte-compiling e:\Python27\lib\encodings\euc_jp.py to encodings\euc_jp.pyc byte-compiling e:\Python27\lib\encodings\euc_kr.py to encodings\euc_kr.pyc byte-compiling e:\Python27\lib\encodings\gb18030.py to encodings\gb18030.pyc byte-compiling e:\Python27\lib\encodings\gb2312.py to encodings\gb2312.pyc byte-compiling e:\Python27\lib\encodings\gbk.py to encodings\gbk.pyc byte-compiling e:\Python27\lib\encodings\hex_codec.py to encodings\hex_codec.pyc byte-compiling e:\Python27\lib\encodings\hp_roman8.py to encodings\hp_roman8.pyc byte-compiling e:\Python27\lib\encodings\hz.py to encodings\hz.pyc byte-compiling e:\Python27\lib\encodings\idna.py to encodings\idna.pyc byte-compiling e:\Python27\lib\encodings\iso2022_jp.py to encodings\iso2022_jp.pyc byte-compiling e:\Python27\lib\encodings\iso2022_jp_1.py to encodings\iso2022_jp_1.pyc byte-compiling e:\Python27\lib\encodings\iso2022_jp_2.py to encodings\iso2022_jp_2.pyc byte-compiling e:\Python27\lib\encodings\iso2022_jp_2004.py to encodings\iso2022_jp_2004.pyc byte-compiling e:\Python27\lib\encodings\iso2022_jp_3.py to encodings\iso2022_jp_3.pyc byte-compiling e:\Python27\lib\encodings\iso2022_jp_ext.py to encodings\iso2022_jp_ext.pyc byte-compiling e:\Python27\lib\encodings\iso2022_kr.py to encodings\iso2022_kr.pyc byte-compiling e:\Python27\lib\encodings\iso8859_1.py to encodings\iso8859_1.pyc byte-compiling e:\Python27\lib\encodings\iso8859_10.py to encodings\iso8859_10.pyc byte-compiling e:\Python27\lib\encodings\iso8859_11.py to encodings\iso8859_11.pyc byte-compiling e:\Python27\lib\encodings\iso8859_13.py to encodings\iso8859_13.pyc byte-compiling e:\Python27\lib\encodings\iso8859_14.py to encodings\iso8859_14.pyc byte-compiling e:\Python27\lib\encodings\iso8859_15.py to encodings\iso8859_15.pyc byte-compiling e:\Python27\lib\encodings\iso8859_16.py to encodings\iso8859_16.pyc byte-compiling e:\Python27\lib\encodings\iso8859_2.py to encodings\iso8859_2.pyc byte-compiling e:\Python27\lib\encodings\iso8859_3.py to encodings\iso8859_3.pyc byte-compiling e:\Python27\lib\encodings\iso8859_4.py to encodings\iso8859_4.pyc byte-compiling e:\Python27\lib\encodings\iso8859_5.py to encodings\iso8859_5.pyc byte-compiling e:\Python27\lib\encodings\iso8859_6.py to encodings\iso8859_6.pyc byte-compiling e:\Python27\lib\encodings\iso8859_7.py to encodings\iso8859_7.pyc byte-compiling e:\Python27\lib\encodings\iso8859_8.py to encodings\iso8859_8.pyc byte-compiling e:\Python27\lib\encodings\iso8859_9.py to encodings\iso8859_9.pyc byte-compiling e:\Python27\lib\encodings\johab.py to encodings\johab.pyc byte-compiling e:\Python27\lib\encodings\koi8_r.py to encodings\koi8_r.pyc byte-compiling e:\Python27\lib\encodings\koi8_u.py to encodings\koi8_u.pyc byte-compiling e:\Python27\lib\encodings\latin_1.py to encodings\latin_1.pyc byte-compiling e:\Python27\lib\encodings\mac_arabic.py to encodings\mac_arabic.pyc byte-compiling e:\Python27\lib\encodings\mac_centeuro.py to encodings\mac_centeuro.pyc byte-compiling e:\Python27\lib\encodings\mac_croatian.py to encodings\mac_croatian.pyc byte-compiling e:\Python27\lib\encodings\mac_cyrillic.py to encodings\mac_cyrillic.pyc byte-compiling e:\Python27\lib\encodings\mac_farsi.py to encodings\mac_farsi.pyc byte-compiling e:\Python27\lib\encodings\mac_greek.py to encodings\mac_greek.pyc byte-compiling e:\Python27\lib\encodings\mac_iceland.py to encodings\mac_iceland.pyc byte-compiling e:\Python27\lib\encodings\mac_latin2.py to encodings\mac_latin2.pyc byte-compiling e:\Python27\lib\encodings\mac_roman.py to encodings\mac_roman.pyc byte-compiling e:\Python27\lib\encodings\mac_romanian.py to encodings\mac_romanian.pyc byte-compiling e:\Python27\lib\encodings\mac_turkish.py to encodings\mac_turkish.pyc byte-compiling e:\Python27\lib\encodings\mbcs.py to encodings\mbcs.pyc byte-compiling e:\Python27\lib\encodings\palmos.py to encodings\palmos.pyc byte-compiling e:\Python27\lib\encodings\ptcp154.py to encodings\ptcp154.pyc byte-compiling e:\Python27\lib\encodings\punycode.py to encodings\punycode.pyc byte-compiling e:\Python27\lib\encodings\quopri_codec.py to encodings\quopri_codec.pyc byte-compiling e:\Python27\lib\encodings\raw_unicode_escape.py to encodings\raw_unicode_escape.pyc byte-compiling e:\Python27\lib\encodings\rot_13.py to encodings\rot_13.pyc byte-compiling e:\Python27\lib\encodings\shift_jis.py to encodings\shift_jis.pyc byte-compiling e:\Python27\lib\encodings\shift_jis_2004.py to encodings\shift_jis_2004.pyc byte-compiling e:\Python27\lib\encodings\shift_jisx0213.py to encodings\shift_jisx0213.pyc byte-compiling e:\Python27\lib\encodings\string_escape.py to encodings\string_escape.pyc byte-compiling e:\Python27\lib\encodings\tis_620.py to encodings\tis_620.pyc byte-compiling e:\Python27\lib\encodings\undefined.py to encodings\undefined.pyc byte-compiling e:\Python27\lib\encodings\unicode_escape.py to encodings\unicode_escape.pyc byte-compiling e:\Python27\lib\encodings\unicode_internal.py to encodings\unicode_internal.pyc byte-compiling e:\Python27\lib\encodings\utf_16.py to encodings\utf_16.pyc byte-compiling e:\Python27\lib\encodings\utf_16_be.py to encodings\utf_16_be.pyc byte-compiling e:\Python27\lib\encodings\utf_16_le.py to encodings\utf_16_le.pyc byte-compiling e:\Python27\lib\encodings\utf_32.py to encodings\utf_32.pyc byte-compiling e:\Python27\lib\encodings\utf_32_be.py to encodings\utf_32_be.pyc byte-compiling e:\Python27\lib\encodings\utf_32_le.py to encodings\utf_32_le.pyc byte-compiling e:\Python27\lib\encodings\utf_7.py to encodings\utf_7.pyc byte-compiling e:\Python27\lib\encodings\utf_8.py to encodings\utf_8.pyc byte-compiling e:\Python27\lib\encodings\utf_8_sig.py to encodings\utf_8_sig.pyc byte-compiling e:\Python27\lib\encodings\uu_codec.py to encodings\uu_codec.pyc byte-compiling e:\Python27\lib\encodings\zlib_codec.py to encodings\zlib_codec.pyc byte-compiling e:\Python27\lib\fnmatch.py to fnmatch.pyc byte-compiling e:\Python27\lib\functools.py to functools.pyc byte-compiling e:\Python27\lib\genericpath.py to genericpath.pyc byte-compiling e:\Python27\lib\getopt.py to getopt.pyc byte-compiling e:\Python27\lib\gettext.py to gettext.pyc byte-compiling e:\Python27\lib\hashlib.py to hashlib.pyc byte-compiling e:\Python27\lib\heapq.py to heapq.pyc byte-compiling e:\Python27\lib\inspect.py to inspect.pyc byte-compiling e:\Python27\lib\io.py to io.pyc byte-compiling e:\Python27\lib\keyword.py to keyword.pyc byte-compiling e:\Python27\lib\linecache.py to linecache.pyc byte-compiling e:\Python27\lib\locale.py to locale.pyc byte-compiling e:\Python27\lib\logging\__init__.py to logging\__init__.pyc creating I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\collect-2.7\logging byte-compiling e:\Python27\lib\ntpath.py to ntpath.pyc byte-compiling e:\Python27\lib\opcode.py to opcode.pyc byte-compiling e:\Python27\lib\optparse.py to optparse.pyc byte-compiling e:\Python27\lib\os.py to os.pyc byte-compiling e:\Python27\lib\os2emxpath.py to os2emxpath.pyc byte-compiling e:\Python27\lib\pdb.py to pdb.pyc byte-compiling e:\Python27\lib\pickle.py to pickle.pyc byte-compiling e:\Python27\lib\posixpath.py to posixpath.pyc byte-compiling e:\Python27\lib\pprint.py to pprint.pyc byte-compiling e:\Python27\lib\quopri.py to quopri.pyc byte-compiling e:\Python27\lib\random.py to random.pyc byte-compiling e:\Python27\lib\re.py to re.pyc byte-compiling e:\Python27\lib\repr.py to repr.pyc byte-compiling e:\Python27\lib\shlex.py to shlex.pyc byte-compiling e:\Python27\lib\sre.py to sre.pyc byte-compiling e:\Python27\lib\sre_compile.py to sre_compile.pyc byte-compiling e:\Python27\lib\sre_constants.py to sre_constants.pyc byte-compiling e:\Python27\lib\sre_parse.py to sre_parse.pyc byte-compiling e:\Python27\lib\stat.py to stat.pyc byte-compiling e:\Python27\lib\string.py to string.pyc byte-compiling e:\Python27\lib\stringprep.py to stringprep.pyc byte-compiling e:\Python27\lib\struct.py to struct.pyc byte-compiling e:\Python27\lib\subprocess.py to subprocess.pyc byte-compiling e:\Python27\lib\tempfile.py to tempfile.pyc byte-compiling e:\Python27\lib\textwrap.py to textwrap.pyc byte-compiling e:\Python27\lib\threading.py to threading.pyc byte-compiling e:\Python27\lib\token.py to token.pyc byte-compiling e:\Python27\lib\tokenize.py to tokenize.pyc byte-compiling e:\Python27\lib\traceback.py to traceback.pyc byte-compiling e:\Python27\lib\types.py to types.pyc byte-compiling e:\Python27\lib\unittest\__init__.py to unittest\__init__.pyc creating I:\Test\PythonTest\PyPrj1\build\bdist.win32\winexe\collect-2.7\unittest byte-compiling e:\Python27\lib\unittest\case.py to unittest\case.pyc byte-compiling e:\Python27\lib\unittest\loader.py to unittest\loader.pyc byte-compiling e:\Python27\lib\unittest\main.py to unittest\main.pyc byte-compiling e:\Python27\lib\unittest\result.py to unittest\result.pyc byte-compiling e:\Python27\lib\unittest\runner.py to unittest\runner.pyc byte-compiling e:\Python27\lib\unittest\signals.py to unittest\signals.pyc byte-compiling e:\Python27\lib\unittest\suite.py to unittest\suite.pyc byte-compiling e:\Python27\lib\unittest\util.py to unittest\util.pyc byte-compiling e:\Python27\lib\warnings.py to warnings.pyc byte-compiling e:\Python27\lib\weakref.py to weakref.pyc *** copy extensions *** copying e:\Python27\DLLs\_hashlib.pyd -> I:\Test\PythonTest\PyPrj1\dist copying e:\Python27\DLLs\bz2.pyd -> I:\Test\PythonTest\PyPrj1\dist copying e:\Python27\DLLs\select.pyd -> I:\Test\PythonTest\PyPrj1\dist copying e:\Python27\DLLs\unicodedata.pyd -> I:\Test\PythonTest\PyPrj1\dist *** copy dlls *** copying e:\Python27\w9xpopen.exe -> I:\Test\PythonTest\PyPrj1\dist copying C:\Windows\system32\python27.dll -> I:\Test\PythonTest\PyPrj1\dist setting sys.winver for 'I:\Test\PythonTest\PyPrj1\dist\python27.dll' to 'py2exe' copying e:\Python27\lib\site-packages\py2exe\run.exe -> I:\Test\PythonTest\PyPrj1\dist\CalcMD5.exe *** binary dependencies *** Your executable(s) also depend on these dlls which are not included, you may or may not need to distribute them. Make sure you have the license if you distribute any of them, and make sure you don't distribute files belonging to the operating system. USER32.dll - C:\Windows\system32\USER32.dll SHELL32.dll - C:\Windows\system32\SHELL32.dll ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll WS2_32.dll - C:\Windows\system32\WS2_32.dll GDI32.dll - C:\Windows\system32\GDI32.dll KERNEL32.dll - C:\Windows\system32\KERNEL32.dll
build目录是转换时生成的临时文件,最终转换出来的文件存放在dist目录中。执行CalcMD5.exe就可以打印出Hello字符串了。
最后将dist目录打包,就可以拷贝给他人使用了
Py2exe仅支持windows平台,其他python脚本转可执行程序工具
① Pyinstaller支持windows/linux/Mac osx,它本身并不是python模块。
② Py2app是把mac osx下的python程序打包的工具。