美文网首页
python应用程序包生成工具PyInstaller

python应用程序包生成工具PyInstaller

作者: lissettecarlr | 来源:发表于2019-05-22 09:56 被阅读0次

前言

其实吧,想知道关于这个工具,打开它的github就可以了

正文

就是简单使用和问题记录
安装

pip install pyinstaller

1 生成执行文件

pyinstaller -F  .\at_tool.py --noconsole

其中-F是为了仅生成执行文件,--noconsole是为了在打开GUI后不再继续显示黑窗
附上pyinstaller的一些命令,此图来源于该博文

image.png

2 问题

生成中我是没有遇到问题,之后遇到再记录,执行是黑窗一闪而过,于是使用cmd来执行exe文件,这样可以看到打印的错误,我的错误是找不到我代码中打开的文件,因为没有给路径,生成的exe就在它自己当前路径里面搜索,我直接将用的那几个文件扔到了它的目录来解决。

如果使用pip安装遇到下载的时候报错

THESE PACKAGES DO NOT MATCH THE HASHES FROM THE 
REQUIREMENTS FILE. If you have updated the package versions, please 
update the hashes. Otherwise, examine the package contents carefully;
someone may have tampered with them.

可以尝试直接去下载源码
解压进入目录执行

cd bootloader
python3  ./waf distclean all

最后安装

python3 setup.py install

如果报错缺少altgraph那么安装就是

pkg_resources.DistributionNotFound: 
The 'altgraph' distribution was not found and is required by PyInstaller
pip3 install altgraph

之后打包

pyinstaller -F  at_tool.py --noconsole

以上是在树莓派上安装出现的问题,按照上述处理后成功打包并使用

相关文章

网友评论

      本文标题:python应用程序包生成工具PyInstaller

      本文链接:https://www.haomeiwen.com/subject/vbehzqtx.html