运行 pyinstaller 打包成的exe 闪退

本文详细记录了在使用pyinstaller打包Python程序为exe过程中遇到的问题,包括控制台额外打开、运行闪退、找不到依赖文件和跨环境运行失败等,并提供了相应的解决方法,涉及模块安装、依赖文件放置以及代码修改等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pyinstaller官方文档

虽然是英文,但能看就能少走很多弯路,像使用-F打包,遇到fileNotFoundError之类的问题,都能知其然,知其所以然地解决。

以下是摘录的一段打包单文件的工作原理

The bootloader is the heart of the one-file bundle also. When started it creates a temporary folder in the appropriate temp-folder location for this OS. The folder is named _MEIxxxxxx, where xxxxxx is a random number.
The one executable file contains an embedded archive of all the Python modules used by your script, as well as compressed copies of any non-Python support files (e.g. .so files). The bootloader uncompresses the support files and writes copies into the the temporary folder. This can take a little time. That is why a one-file app is a little slower to start than a one-folder app.
Afte

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值