python转换为exe程序

来源:互联网 发布:"网站seo推广方案ppt" 编辑:程序博客网 时间:2024/06/05 11:58

有人说py2exe太过陈旧缺少维护操作不便,推荐PyInstaller项目www.pyinstaller.org
可用一句命令打包:

pyinstaller -F -w -i manage.ico app.py

-F:打包为单文件
-w:Windows程序,不显示命令行窗口
-i:是程序图标,app.py是你要打包的py文件

另外需要pywin32。

安装方法:
先跑pip install pywin32再跑pip install pyinstaller即可,多么简单。


pyqt5写完win32 应用程序后,经过pyinstaller打包成单个文件,运行弹出错误提示框:failed to execute script main

pycharm中pyinstaller打包参数:

Program:C:\Python\Python35\Scripts\pyinstaller.exe

Parameters: -w -F $FileName$

Working directory: $FileDir$


分析:

经google,发现pyinstaller 有--hidden-import 选项

             --hidden-import MODULENAME,--hiddenimport MODULENAME

                        Name an import not visible in the code of the

                        script(s).Thisoption can be used multiple times.


解决:

打包时加上 --hidden-import=queue

即Parameters配置修改为:

Parameters:--hidden-import=queue -w -F $FileName$


原创粉丝点击