利用PyInstaller将python代码封装成EXE(亲测可用)

时间:2021-02-09 16:32:26

有些不能成功,有些不全的,下面总结一下,给自己以后看看。

 

1下载PyInstaller。。去官网下载http://www.pyinstaller.org/(我下载的版本)

 

2不需要安装,解压即可。如解压到D盘。

 

3进入cmd下面,

利用PyInstaller将python代码封装成EXE(亲测可用)

进入解压的文件下

利用PyInstaller将python代码封装成EXE(亲测可用)

 

4  写一个测试文件保存在D盘下,命名为Hello(参考1)

# -*- coding: utf-8 -*-
"""
Created on Thu Mar 13 14:00:26 2014 @author: Administrator
""" #!/usr/bin/env python
print 'Hello,World!'
words = raw_input('What do you want to say? ')
print 'you said:'+words

 

 

5执行封装:在cmd下写下面的语句。利用PyInstaller将python代码封装成EXE(亲测可用)

参考(2)

利用PyInstaller将python代码封装成EXE(亲测可用)

 

会出下如下结果

利用PyInstaller将python代码封装成EXE(亲测可用)。。。略

 

 

6在D:\PyInstaller-2.1\hello\dist\hello下面的exe就是可执行文件了利用PyInstaller将python代码封装成EXE(亲测可用)

 

 

 

参考1:http://huangliangnumber1.blog.163.com/blog/static/47811748201142282435469/

参考2:http://outofmemory.cn/code-snippet/2041/usage-pyinstaller-dabao-python-exe-file