博主信息
博文 1
粉丝 0
评论 0
访问量 1561
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
pyinstaller打包问题
Mj的博客
原创
1568人浏览过

pyinstaller打包使用pyqt5模块的时候,在win平台下,由于pyinstaller无法准确获取QT动态库文件路径,会报错导致无法打开运行程序,并提示错误信息pyinstaller failed to execute script pyi_rth_qt5plugins此时我们需要在打包的时候直接告诉pyinstaller到哪里去找,这个路径分隔符需要是unix形式:

pyinstaller --paths d:/Python/Python35-32/Lib/site-packages/PyQt5/Qt/bin -F -w ****.py


=======================================================


pyinstaller 打包python脚本成exe,只需要简单的两步:

pip install pyinstaller

pyinstaller script.py

或者将动态链接库也打包到 exe 当中:

pyinstaller --console --onefile script.py

然后在当前目录下回产生两个目录和一个文件:dist、build、.spec ,exe 就在dist当中。

实际操作中,发生 IndexError: tuple index out of range异常,查询官网,原来不支持python3.6.

见 pyinstaller 官网说明:

PyInstaller is a program that freezes (packages) Python programs intostand-alone executables, under Windows, Linux, Mac OS X, FreeBSD,Solaris and AIX. Its main advantages over similar tools are thatPyInstaller works withPython 2.7 and 3.3—3.5, it builds smallerexecutables thanks to transparent compression, it is fullymulti-platform, and use the OS support to load the dynamic libraries,thus ensuring full compatibility.

用 python3.5 重新捣鼓一遍,这次成功了。

可在 exe 执行时,又失败了:

File "site-packages\urllib3\connectionpool.py", line 28, in <module>

  File "site-packages\urllib3\packages\six.py", line 92, in __get__

  File "site-packages\urllib3\packages\six.py", line 115, in _resolve

  File "site-packages\urllib3\packages\six.py", line 82, in _import_module

ImportError: No module named 'queue'

查了下,有三种方法可以解决:

1、requests 包的版本问题,当前使用的是2.17的版本,换成旧版本问题解决(这个方法确实很扯淡):

pip install requests==2.10

2、更好的办法,在导入requests 包的文件中,显示的导入 queue 模块,尽管没有使用到该模块。

在脚本中加入:

import queue

同样问题解决 。

3、在制作的时候,带上 --hidden-import=queue 参数也可。

D:\ProgramData\python3.5\Scripts\pyinstaller.exe --hidden-import=queue D:\wrokingPro\CSDN_visit.py


===============================

pyinstaller --hidden-import=queue -F zc7m.py


本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学