安装pyinstaller:
参考:
命令:
pip3 install pyinstaller -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
具体Log:
(跑出来的log,因为之前单独安装pyinstaller的时候,需要额外安装其他的包,幸好找到这么比较全的,所以把跑出来的log存下来,之后需要的话可以再具体找都有哪些包)
Looking in indexes: http://mirrors.aliyun.com/pypi/simple
Requirement already satisfied: pyinstaller in f:\python\lib\site-packages\pyinst
aller-4.1-py3.7.egg (4.1)
Requirement already satisfied: setuptools in f:\python\lib\site-packages (from p
yinstaller) (47.1.0)
Collecting altgraph
Downloading http://mirrors.aliyun.com/pypi/packages/ee/3d/bfca21174b162f6ce674953f1b7a640c1498357fa6184776029557c25399/altgraph-0.17-py2.py3-none-any.whl (21kB)
Collecting pyinstaller-hooks-contrib>=2020.6
Downloading http://mirrors.aliyun.com/pypi/packages/a4/11/90ac24147907d9b7302983ec66ae46b045b47212906101cc82d9204c798d/pyinstaller_hooks_contrib-2020.11-py2.py3-none-any.whl (172 kB)
Collecting pefile>=2017.8.1
Downloading http://mirrors.aliyun.com/pypi/packages/36/58/acf7f35859d541985f0a
6ea3c34baaefbfaee23642cf11e85fe36453ae77/pefile-2019.4.18.tar.gz (62 kB)
Requirement already satisfied: pywin32-ctypes>=0.2.0 in f:\python\lib\site-packa
ges (from pyinstaller) (0.2.0)
Collecting future
Downloading http://mirrors.aliyun.com/pypi/packages/45/0b/38b06fd9b92dc2b68d58b75f900e97884c45bedd2ff83203d933cf5851c9/future-0.18.2.tar.gz (829 kB)
Using legacy setup.py install for pefile, since package 'wheel' is not installed.
Using legacy setup.py install for future, since package 'wheel' is not installed.
Installing collected packages: altgraph, pyinstaller-hooks-contrib, future, pefile
Running setup.py install for future ... done
Running setup.py install for pefile ... done
Successfully installed altgraph-0.17 future-0.18.2 pefile-2019.4.18 pyinstaller-hooks-contrib-2020.11
使用pyinstaller打包:
参考:
https://link.zhihu.com/?target=https%3A//www.cnblogs.com/it-tsz/p/10534654.html
1、使用下载安装的方式安装的Pyinstaller打包方式
将需要打包的文件放在解压得到的Pyinstaller文件夹中,打开cmd窗口,把路径切换到当前路径打开命令提示行,输入以下内容(最后的是文件名):
python pyinstaller.py -F myfile.py
2、使用pip方式安装的Pyinstaller打包方式
打开cmd窗口,把路径切换到文件所在路径(文件随便放在哪里都行)打开命令提示行,输入以下内容(最后的是文件名):
pyinstaller -F myfile.py
文件中使用了第三方库的打包方式
在打包之前务必找到第三方库的包,把包复制到到跟myfile.py同目录下,然后再使用以上2种方式打包,否则会打包失败或者即使打包成功,程序也会闪退。
找到第三方库的包,如使用了requests,可以使用查找的方式,找到这个包在哪里,然后把它复制到myfile.py同目录下