python腳本生成exe可執行文件
2016-03-20 13:58 by 冷水菜, ... 閱讀, ... 評論, 收藏, 編輯1.先安裝第三方插件:
py2exe. Get py2exe from http://www.py2exe.org/
在download裏下載與自己python對應的版本
2.寫一個測試python文件
Ttest.py
print "Python script to exe test program" count = 0 while count < 10: print "count = " + str(count) +"\n" count = count + 1
cmd中運行
3.寫setup腳本,用於指定可執行程序的入口點
我把setup.py和Ttest.py放到一個目的,自己注意下文件位置
from distutils.core import setup import py2exe setup(console=['Ttest.py'])
4.在cmd下用py2exe生成
代碼:python setup.py py2exe
之後會生成dist和build文件夾,dist裏的就是發佈的exe和相關dll