簡體   English   中英

pyinstaller 不適用於 pyqt5 和 matplotlib

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

我使用 pyqt5 創建 gui 並使用 matplotlib

但是當我嘗試使用 pyinstaller 創建可執行文件時,它不起作用

我嘗試了一些解決方案,例如:

1- 無法使用 PyInstaller/ 創建工作 PyQt5 Python 可執行文件

2- 在 PyInstaller 中,為什么 NumPy.Random.Common 不能作為模塊加載?

3- PyInstaller 生成的可執行文件中的 Python SSL 導入錯誤

我嘗試使用 cx_Freeze 執行此操作並嘗試此解決方案cx_Freeze error: baseline image directory does not exist

但對我沒有任何幫助

這是我使用 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.

是否有另一種方法可以使用包含 pyqt5 和 matplotlib 和 Qchart 的 pyinstaller 制作 exe

您可以嘗試降級您似乎沒有提及的 matplotlib 版本。 3.1.3在我的情況下使用 PyInstaller 和 PyQt5 修復了它。

感謝@LittleFoxyFox 解決了,這是使用 cx_Freeze 的另一種方法

在導入區添加

import PIL
import tkinter
from tkinter import filedialog

並將 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

並使用以下 lignes 創建另一個 py 文件(在我的情況下為 setup_2.py)

from cx_Freeze import setup, Executable

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

將 PyQt 降級到 5.15.0

並在終端

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

這將使它工作,但使用 cx_freeze

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM