python2.7生成exe可執行文件

1.安裝對應python版本的py2exepython

  py2exe下載地址spa

2.假設你要生成test.py腳本的exe文件code

  新建一個setup.py,在裏面輸入以下代碼blog

1 #!/usr/bin/python   
2 from distutils.core import setup  
3 import py2exe  
4 import os,sys  
5   
6 CurrentPath = os.path.dirname(sys.argv[0]) 
7 setup(console=[str(CurrentPath)+'test.py'])  

  保存退出get

3.打開cmd,輸入命令cmd

python   setup.py   py2exe

成功後在dist文件夾中就會生成exe文件了。console

相關文章
相關標籤/搜索