python pyinstaller打包exe报错的解决方法
作者:烟雨半生 时间:2022-05-11 20:39:40
今天用python 使用pyinstaller打包exe出现错误
环境pyqt5 + python3.6 32位
在导入pyqt5包之前加上如下代码
import sys
import os
if hasattr(sys, 'frozen'):
os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH']
from PyQt5.QtWidgets import QApplication, QMainWindow
from pyqt_ui.MainWindow import MainWin
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWindow = QMainWindow()
main_dialog = MainWin(mainWindow)
mainWindow.show()
sys.exit(app.exec_())
运行
pyinstaller -F main2.py
INFO: PyInstaller: 3.5
INFO: Python: 3.6.4
INFO: Platform: Windows-7-6.1.7601-SP1
INFO: wrote E:\workspace\devTest\main2.spec
INFO: UPX is not available.
INFO: Extending PYTHONPATH with paths
['E:\\workspace\\devTest', 'E:\\workspace\\devTest']
INFO: checking Analysis
INFO: Building because E:\workspace\devTest\main2.py changed
INFO: Initializing module dependency graph...
INFO: Initializing module graph hooks...
INFO: Analyzing base_library.zip ...
INFO: running Analysis Analysis-00.toc
INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by d:\mytool\env\env36-32\scripts\python.exe
INFO: Caching module hooks...
INFO: Analyzing E:\workspace\devTest\main2.py
INFO: Processing pre-find module path hook distutils
INFO: distutils: retargeting to non-venv dir 'C:\\Program Files (x86)\\Python36-32\\Lib\\distutils\\__init__.py'
INFO: Processing pre-safe import module hook win32com
INFO: Loading module hooks...
INFO: Loading module hook "hook-encodings.py"...
INFO: Loading module hook "hook-pydoc.py"...
INFO: Loading module hook "hook-PyQt5.py"...
WARNING: Hidden import "sip" not found!
INFO: Loading module hook "hook-PyQt5.QtCore.py"...
INFO: Loading module hook "hook-PyQt5.QtGui.py"...
INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
INFO: Loading module hook "hook-pythoncom.py"...
INFO: Loading module hook "hook-pywintypes.py"...
INFO: Loading module hook "hook-win32com.py"...
INFO: Loading module hook "hook-xml.py"...
INFO: Looking for ctypes DLLs
INFO: Analyzing run-time hooks ...
INFO: Including run-time hook 'pyi_rth_pyqt5.py'
INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
INFO: Looking for dynamic libraries
INFO: Looking for eggs
INFO: Using Python library d:\mytool\env\env36-32\scripts\python36.dll
INFO: Found binding redirects:
[]
INFO: Warnings written to E:\workspace\devTest\build\main2\warn-main2.txt
INFO: Graph cross-reference written to E:\workspace\devTest\build\main2\xref-main2.html
INFO: checking PYZ
INFO: Building because toc changed
INFO: Building PYZ (ZlibArchive) E:\workspace\devTest\build\main2\PYZ-00.pyz
INFO: Building PYZ (ZlibArchive) E:\workspace\devTest\build\main2\PYZ-00.pyz completed successfully.
INFO: checking PKG
INFO: Building because toc changed
INFO: Building PKG (CArchive) PKG-00.pkg
WARNING: One binary added with two internal names.
WARNING: ('libGLESv2.dll',
'D:\\mytool\\env\\env36-32\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
'BINARY')
WARNING: was placed previously at
WARNING: ('PyQt5\\Qt\\bin\\libGLESv2.dll',
'D:\\mytool\\env\\env36-32\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
'BINARY')
INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
INFO: Bootloader d:\mytool\env\env36-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
INFO: checking EXE
INFO: Building because toc changed
INFO: Building EXE from EXE-00.toc
INFO: Appending archive to EXE E:\workspace\devTest\dist\main2.exe
INFO: Building EXE from EXE-00.toc completed successfully.
打包成功
运行出现正常界面
注:为避免重复将main.py 更改为main2.py了
来源:https://www.cnblogs.com/yubs/p/11779511.html
标签:python,pyinstaller,打包
0
投稿
猜你喜欢
jsp下页面跳转的几种方法小结
2023-07-22 00:38:07
firebug1.7调试实用技巧指南
2011-06-27 20:17:22
Mysql的最大连接数怎样用java程序测试
2009-01-14 12:05:00
js购物车实现思路及代码(个人感觉不错)
2024-04-18 10:59:06
Go语言反射reflect.Value实现方法的调用
2023-07-22 15:50:11
记一次python 爬虫爬取深圳租房信息的过程及遇到的问题
2022-03-22 02:09:02
如何用ASP输出HTML文件?
2010-06-11 20:01:00
python 经纬度求两点距离、三点面积操作
2021-05-16 17:48:17
python字符串循环左移
2023-08-28 19:32:13
简析Oracle数据库常见问题及解决方案
2024-01-24 11:15:01
如何使用pandas读取txt文件中指定的列(有无标题)
2022-04-25 15:30:18
一文教你利用Python制作一个C盘清理器
2022-05-05 00:45:20
python 使用百度AI接口进行人脸对比的步骤
2021-07-06 02:20:06
golang获取网卡信息操作
2024-02-22 01:57:17
python获取文件版本信息、公司名和产品名的方法
2022-05-31 17:30:23
一小时学会TensorFlow2之自定义层
2021-12-22 18:00:11
Python实现在Excel文件中写入图表
2023-11-20 17:13:03
go并发实现素数筛的代码
2024-04-27 15:38:03
js实现axios限制请求队列
2024-05-10 13:59:31
Python Map 函数的使用
2023-09-02 06:27:17