1. 各種打包工具的對比如下(來自文章Freezing Your Code):
Solution | Windows | Linux | OS X | Python 3 | License | One-file mode | Zipfile import | Eggs | pkg_resources support |
---|---|---|---|---|---|---|---|---|---|
bbFreeze | yes | yes | yes | no | MIT | no | yes | yes | yes |
py2exe | yes | no | no | yes | MIT | yes | yes | no | no |
pyInstaller | yes | yes | yes | no | GPL | yes | no | yes | no |
cx_Freeze | yes | yes | yes | yes | PSF | no | yes | yes | no |
py2app | no | no | yes | yes | MIT | no | yes | yes | yes |
2. py2exe
參照https://blog.csdn.net/linda1000/article/details/12909439
簡單實用方法如下:
- #mysetup.py
- from distutils.core import setup
- import py2exe
- setup(console=["helloworld.py"])
[python] view plain copy
- python mysetup.py py2exe
3. pyInstaller(離線環境)
https://pypi.org 搜 pyInstaller下載下傳,pip install
常見問題: 離線時無法下載下傳依賴包,依次安裝future和pefile,最後安裝pyInstaller。實際操作過程中根據提示,安裝相應的依賴庫。
簡單使用方法如下:
pyinstaller helloword.py