Blogger Information
Blog 1
fans 0
comment 0
visits 1296
Related recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
pyinstaller打包问题
Mj的博客
Original
1303 people have browsed it

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


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post