简体   繁体   English

pyinstaller 不适用于 pyqt5 和 matplotlib

[英]pyinstaller does not work with with pyqt5 and matplotlib

im using pyqt5 to create a gui and using matplotlib我使用 pyqt5 创建 gui 并使用 matplotlib

but whene i try to create executable with pyinstaller it dose not work但是当我尝试使用 pyinstaller 创建可执行文件时,它不起作用

i try a few solution like :我尝试了一些解决方案,例如:

1- Can't create working PyQt5 Python executable with PyInstaller/ 1- 无法使用 PyInstaller/ 创建工作 PyQt5 Python 可执行文件

2- In PyInstaller, Why Won't NumPy.Random.Common Load as a Module? 2- 在 PyInstaller 中,为什么 NumPy.Random.Common 不能作为模块加载?

3- Python SSL Import Error in PyInstaller generated executable 3- PyInstaller 生成的可执行文件中的 Python SSL 导入错误

i try to do it with cx_Freeze and try this solution cx_Freeze error: baseline image directory does not exist我尝试使用 cx_Freeze 执行此操作并尝试此解决方案cx_Freeze error: baseline image directory does not exist

but nothing work with me但对我没有任何帮助

this is my log after using pyinstaller这是我使用 pyinstaller 后的日志

78 INFO: PyInstaller: 4.0
78 INFO: Python: 3.8.2
78 INFO: Platform: Windows-8-6.2.9200-SP0
78 INFO: wrote E:\new caissier_localhost\admin_copie\admin_admin.spec
78 INFO: UPX is not available.
78 INFO: Extending PYTHONPATH with paths
['E:\\new caissier_localhost\\admin_copie',
 'E:\\new caissier_localhost\\admin_copie']
93 INFO: checking Analysis
154 INFO: Building because E:\new caissier_localhost\admin_copie\admin_admin.py changed
154 INFO: Initializing module dependency graph...
158 INFO: Caching module graph hooks...
178 INFO: Analyzing base_library.zip ...
3427 INFO: Processing pre-find module path hook distutils from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
3427 INFO: distutils: retargeting to non-venv dir 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib'
7418 INFO: Caching module dependency graph...
7600 INFO: running Analysis Analysis-00.toc
7600 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
 
79139 INFO: checking PKG
79154 INFO: Building because toc changed
79154 INFO: Building PKG (CArchive) PKG-00.pkg
123333 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
123441 INFO: Bootloader c:\users\zakaria\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
123441 INFO: checking EXE
123473 INFO: Building because toc changed
123473 INFO: Building EXE from EXE-00.toc
123473 INFO: Copying icons from ['sifax.ico']
123489 INFO: Writing RT_GROUP_ICON 0 resource with 90 bytes
123489 INFO: Writing RT_ICON 1 resource with 35796 bytes
123489 INFO: Writing RT_ICON 2 resource with 67624 bytes
123489 INFO: Writing RT_ICON 3 resource with 16936 bytes
123489 INFO: Writing RT_ICON 4 resource with 9640 bytes
123489 INFO: Writing RT_ICON 5 resource with 4264 bytes
123489 INFO: Writing RT_ICON 6 resource with 1128 bytes
123492 INFO: Updating manifest in E:\new caissier_localhost\admin_copie\build\admin_admin\runw.exe.k_fyw9z3
123505 INFO: Updating resource type 24 name 1 language 0
123507 INFO: Appending archive to EXE E:\new caissier_localhost\admin_copie\dist\admin_admin.exe
124030 INFO: Building EXE from EXE-00.toc completed successfully.

is there another way to make a exe with pyinstaller that contain pyqt5 and matplotlib and Qchart是否有另一种方法可以使用包含 pyqt5 和 matplotlib 和 Qchart 的 pyinstaller 制作 exe

You can try and downgrade your matplotlib version, which you don't seem to mention.您可以尝试降级您似乎没有提及的 matplotlib 版本。 3.1.3 fixed it in my case using PyInstaller and PyQt5. 3.1.3在我的情况下使用 PyInstaller 和 PyQt5 修复了它。

solved thanks to @LittleFoxyFox and here is another way with cx_Freeze感谢@LittleFoxyFox 解决了,这是使用 cx_Freeze 的另一种方法

in the import area add在导入区添加

import PIL
import tkinter
from tkinter import filedialog

and change backend_qt4agg to backend_qt5aggb in并将 backend_qt4agg 更改为 backend_qt5aggb

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT as NavigationToolbar
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure

and create another py file with the following lignes ( in my case setup_2.py)并使用以下 lignes 创建另一个 py 文件(在我的情况下为 setup_2.py)

from cx_Freeze import setup, Executable

setup(name = "admiiiin",
    version = "0.10",
    descreption = ".....",
    executables = [Executable("admin_admin.py")]
)

downgrade PyQt to 5.15.0将 PyQt 降级到 5.15.0

and in the terminal并在终端

python setup_2.py build_exe --excludes=matplotlib.tests,numpy.random._examples

that will make it work but with cx_freeze这将使它工作,但使用 cx_freeze

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM