详解Python3.6的py文件打包生成exe

yipeiwu_com7年前Python基础

原文提到的要点:

1. Python版本32位 (文件名为 python-3.6.1.exe)

2. 安装所有用到的模块(原文博主用的是openpyxl,我用到的有urllib中的request\config\data)

3. 下载替换pyinstaller(下载pyinstaller-develop.zip,复制其中的Pyinstaller文件夹)

4. 在控制台生成exe

操作过程记录如下:

C:\Python\Scripts>pip install request
C:\Python\Scripts>pip install config
C:\Python\Scripts>pip install data
C:\Python\Scripts>pyinstaller.exe -F structs2.py

生成成功界面内容:

24957 INFO: checking EXE
24957 INFO: Building EXE because out00-EXE.toc is non existent
24957 INFO: Building EXE from out00-EXE.toc
24958 INFO: Appending archive to EXE C:\Python\Scripts\dist\structs2.exe
24975 INFO: Building EXE from out00-EXE.toc completed successfully.

之前失败了很多次,Python 3 转 exe 失败原因总结:

1. Python开发环境版本、环境变量不一致。之前错误的安装了(python-3.6.2rc1.exe)

2. 注意版本,之前尝试了多个版本,最后全部卸掉重新安装才成功

3. Python包要安装全,之前我没有装request \config等包,也可能是失败原因之一

曾有失败,内容如下:

usage: setup.exe [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.exe --help [cmd1 cmd2 ...]
or: setup.exe --help-commands
or: setup.exe cmd --help

解决方法是重新清理安装开发环境。终于成功。

相关文章

python中stdout输出不缓存的设置方法

考虑以下python程序:复制代码 代码如下:#!/usr/bin/env pythonimport syssys.stdout.write("stdout1 ")sys.stderr....

python同时遍历数组的索引和值的实例

你想在迭代一个序列的同时跟踪正在被处理的元素索引。 获取索引 内置的 enumerate() 函数可以很好的解决这个问题: >>> my_list = ['a',...

Python分析学校四六级过关情况

Python分析学校四六级过关情况

这段时间看了数据分析方面的内容,对Python中的numpy和pandas有了最基础的了解。我知道如果我不用这些技能做些什么的话,很快我就会忘记。想起之前群里发过一个学校的四六级成绩表,...

对python的输出和输出格式详解

对python的输出和输出格式详解

输出 1. 普通的输出 # 打印提示 print('hello world') 用print()在括号中加上字符串,就可以向屏幕上输出指定的文字。比如输出'hello, world...

一看就懂得Python的math模块

math模块 # 数学相关模块 import math r = math.floor(3.2) # 向下取整 print(r) r = math.ceil(4.5) # 向上取整...