windows平台上将python源代码打包成exe

版权声明:本文为博主原创文章,转载请注明来源!获取更新内容请关注我的开源项目:https://github.com/zcc0721/MasterBlockchain https://blog.csdn.net/u013137970/article/details/49205519

以下总结是在windows平台测试的

1、准备工作

首先需要下载Pyinstallerpywin32这两个软件。

pyinstaller官方地址:

http://www.pyinstaller.org/

github下载地址:

https://github.com/pyinstaller/pyinstaller/releases

Pywin32下载地址:

http://sourceforge.net/projects/pywin32/files/pywin32/

注意选择适合自己 电脑的版本下载!

 

2、安装pywin32

pywin32已经安装的人这一步可以跳过了。

如果安装第一步就显示如下,就说明你下载的pywin32版本不对,需要重新下载一个。

 

 

当如果下载的版本正确,则一路next就行了。

 

3、安装pyinstaller

选择一个你喜欢的目录,将下载好的pyinstaller压缩包解压就算安装好了。

 

4、开始打包第一个exe

cmd中运行:

pythonpyinstaller.py [opts] yourprogram.py

其中,选项[opts]有很多可以选择,其中四个最常用的四个选项见下表:

 

-F, 

--onefile

生成单个可执行文件

-D, --onedir

如果没有规定生成单个问价,则默认生成一个文件夹

-o DIR, 

--out=DIR

指定生成文件存放位置

-n NAME, 

--name=NAME

指定生成的项目名称

猜你喜欢

转载自blog.csdn.net/u013137970/article/details/49205519