pyinstaller 不适用于 pyqt5 和 matplotlib
Posted
技术标签:
【中文标题】pyinstaller 不适用于 pyqt5 和 matplotlib【英文标题】:pyinstaller does not work with with pyqt5 and matplotlib 【发布时间】:2020-11-17 16:09:50 【问题描述】:我使用 pyqt5 创建 gui 并使用 matplotlib
但是当我尝试使用 pyinstaller 创建可执行文件时它不起作用
我尝试了一些解决方案,例如:
1-Can't create working PyQt5 Python executable with PyInstaller/
2-In PyInstaller, Why Won't NumPy.Random.Common Load as a Module?
3-Python SSL Import Error in PyInstaller generated executable
我尝试使用 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
required by c:\users\zakaria\appdata\local\programs\python\python38\python.exe
7911 INFO: Analyzing E:\new caissier_localhost\admin_copie\admin_admin.py
9638 INFO: Processing pre-find module path hook site from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
9654 INFO: site: retargeting to fake-dir 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\fake-modules'
11400 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-setuptools.extern.six.moves.py'.
20357 INFO: Processing pre-safe import module hook six.moves from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
39185 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
44167 INFO: Processing pre-find module path hook PyQt5.uic.port_v2 from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-PyQt5.uic.port_v2.py'.
45829 INFO: Processing module hooks...
45829 INFO: Loading module hook 'hook-certifi.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
45845 INFO: Loading module hook 'hook-nltk.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
46884 INFO: Loading module hook 'hook-psycopg2.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
46884 WARNING: Hidden import "mx.DateTime" not found!
46884 INFO: Loading module hook 'hook-regex.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
46884 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
46884 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
46985 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
47059 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
47670 INFO: Matplotlib backend "GTK3Agg": ignored
backend Gtk3Agg requires cairo
47970 INFO: Matplotlib backend "GTK3Cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
48277 INFO: Matplotlib backend "MacOSX": ignored
cannot import name '_macosx' from 'matplotlib.backends' (c:\users\zakaria\appdata\local\programs\python\python38\lib\site-packages\matplotlib\backends\__init__.py)
48598 INFO: Matplotlib backend "nbAgg": ignored
No module named 'IPython'
<string>:12: MatplotlibDeprecationWarning:
The matplotlib.backends.backend_qt4agg backend was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
49212 INFO: Matplotlib backend "Qt4Agg": added
49511 INFO: Matplotlib backend "Qt4Cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
50124 INFO: Matplotlib backend "Qt5Agg": added
50432 INFO: Matplotlib backend "Qt5Cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
50972 INFO: Matplotlib backend "TkAgg": added
51507 INFO: Matplotlib backend "TkCairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
52026 INFO: Matplotlib backend "WebAgg": added
52545 INFO: Matplotlib backend "WX": ignored
No module named 'wx'
52846 INFO: Matplotlib backend "WXAgg": ignored
No module named 'wx'
53158 INFO: Matplotlib backend "WXCairo": ignored
No module named 'wx'
53537 INFO: Matplotlib backend "agg": added
53851 INFO: Matplotlib backend "cairo": ignored
cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
54370 INFO: Matplotlib backend "pdf": added
54905 INFO: Matplotlib backend "pgf": added
55292 INFO: Matplotlib backend "ps": added
55677 INFO: Matplotlib backend "svg": added
56194 INFO: Matplotlib backend "template": added
56510 INFO: Loading module hook 'hook-matplotlib.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
56837 INFO: Loading module hook 'hook-numpy.core.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
56852 INFO: Loading module hook 'hook-numpy.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
56852 INFO: Loading module hook 'hook-pandas.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
57739 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
58113 INFO: Loading module hook 'hook-PIL.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
58113 INFO: Import to be excluded not found: 'FixTk'
58113 INFO: Excluding import 'PyQt4'
58113 INFO: Removing import of PyQt4 from module PIL.ImageQt
58113 INFO: Excluding import 'PyQt5'
58129 INFO: Removing import of PyQt5.QtGui from module PIL.ImageQt
58129 INFO: Removing import of PyQt5.QtCore from module PIL.ImageQt
58129 INFO: Excluding import 'tkinter'
58129 INFO: Removing import of tkinter from module PIL.ImageTk
58129 INFO: Excluding import 'PySide'
58129 INFO: Removing import of PySide from module PIL.ImageQt
58129 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
58129 INFO: Excluding import 'tkinter'
58145 INFO: Import to be excluded not found: 'FixTk'
58146 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
58742 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
59090 WARNING: Hidden import "pkg_resources.py2_warn" not found!
59207 WARNING: Hidden import "pkg_resources.markers" not found!
59223 INFO: Excluding import '__main__'
59223 INFO: Removing import of __main__ from module pkg_resources
59223 INFO: Loading module hook 'hook-PyQt5.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
59387 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
59577 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
59849 INFO: Loading module hook 'hook-PyQt5.QtPrintSupport.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
60237 INFO: Loading module hook 'hook-PyQt5.QtSql.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
60647 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
60950 INFO: Loading module hook 'hook-PyQt5.uic.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
60950 INFO: Loading module hook 'hook-PySide2.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
62235 INFO: Loading module hook 'hook-PySide2.QtCore.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
62366 INFO: Loading module hook 'hook-PySide2.QtGui.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
62656 INFO: Loading module hook 'hook-PySide2.QtNetwork.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63067 INFO: Loading module hook 'hook-PySide2.QtWidgets.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63398 INFO: Loading module hook 'hook-pytz.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63646 INFO: Loading module hook 'hook-scipy.linalg.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63646 INFO: Loading module hook 'hook-scipy.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63646 INFO: Loading module hook 'hook-scipy.sparse.csgraph.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63646 INFO: Loading module hook 'hook-scipy.special._ellip_harm_2.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63646 INFO: Loading module hook 'hook-scipy.special._ufuncs.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63646 INFO: Loading module hook 'hook-scipy.stats._stats.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
63662 INFO: Loading module hook 'hook-setuptools.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
64453 INFO: Loading module hook 'hook-sqlalchemy.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
64668 INFO: Found 4 sqlalchemy hidden imports
64668 WARNING: Hidden import "pysqlite2" not found!
64668 WARNING: Hidden import "mysqldb" not found!
66514 WARNING: Hidden import "sqlalchemy.sql.functions.func" not found!
66529 INFO: Import to be excluded not found: 'sqlalchemy.testing'
66529 INFO: Loading module hook 'hook-sqlite3.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
66616 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
66616 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
66616 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
66616 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
66616 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
66763 INFO: checking Tree
66835 INFO: checking Tree
66850 INFO: Loading module hook 'hook-pythoncom.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
67205 INFO: Loading module hook 'hook-pywintypes.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
67583 INFO: Loading module hook 'hook-win32com.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
67670 INFO: Loading module hook 'hook-packaging.py' from 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks'...
67895 INFO: Looking for ctypes DLLs
68180 INFO: Analyzing run-time hooks ...
68216 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
68220 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
68222 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32comgenpy.py'
68225 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_nltk.py'
68227 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyside2.py'
68228 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_certifi.py'
68230 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
68231 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_mplconfig.py'
68232 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_mpldata.py'
68233 INFO: Including run-time hook 'c:\\users\\zakaria\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyqt5.py'
68285 INFO: Looking for dynamic libraries
70226 WARNING: lib not found: shiboken2.abi3.dll dependency of c:\users\zakaria\appdata\local\programs\python\python38\lib\site-packages\PySide2\QtCore.pyd
70242 WARNING: lib not found: shiboken2.abi3.dll dependency of c:\users\zakaria\appdata\local\programs\python\python38\lib\site-packages\PySide2\QtWidgets.pyd
70282 WARNING: lib not found: shiboken2.abi3.dll dependency of c:\users\zakaria\appdata\local\programs\python\python38\lib\site-packages\PySide2\QtNetwork.pyd
70320 WARNING: lib not found: shiboken2.abi3.dll dependency of c:\users\zakaria\appdata\local\programs\python\python38\lib\site-packages\PySide2\QtGui.pyd
71799 WARNING: lib not found: shiboken2.abi3.dll dependency of c:\users\zakaria\appdata\local\programs\python\python38\lib\site-packages\PySide2\pyside2.abi3.dll
72103 INFO: Looking for eggs
72103 INFO: Using Python library c:\users\zakaria\appdata\local\programs\python\python38\python38.dll
72103 INFO: Found binding redirects:
[]
72140 INFO: Warnings written to E:\new caissier_localhost\admin_copie\build\admin_admin\warn-admin_admin.txt
72646 INFO: Graph cross-reference written to E:\new caissier_localhost\admin_copie\build\admin_admin\xref-admin_admin.html
72867 INFO: checking PYZ
72883 INFO: Building because toc changed
72883 INFO: Building PYZ (ZlibArchive) E:\new caissier_localhost\admin_copie\build\admin_admin\PYZ-00.pyz
79031 INFO: Building PYZ (ZlibArchive) E:\new caissier_localhost\admin_copie\build\admin_admin\PYZ-00.pyz completed successfully.
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
【问题讨论】:
构建看起来很成功,所以可能你的问题是当你运行 exe 时 - 如果你从命令提示符运行什么是完整的错误消息? 从终端运行时没有错误,但问题出在使用 pyinstaller 的 matplotlib 打包中,但在降级 matplotlib 版本后它可以工作 假设您从命令提示符运行 exe,但在/来自不同的文件夹,错误信息是什么? matplotlib 和 pyinstaller 完全没有错误消息 【参考方案1】:您可以尝试降级您似乎没有提及的 matplotlib 版本。 3.1.3
在我的情况下使用 PyInstaller 和 PyQt5 修复了它。
【讨论】:
它可以工作,但是在我将 PyQt 降级到 5.15.0 之后非常感谢您【参考方案2】:感谢@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
【讨论】:
以上是关于pyinstaller 不适用于 pyqt5 和 matplotlib的主要内容,如果未能解决你的问题,请参考以下文章
使用 PyInstaller 在 --onefile 中使用 QML 构建 PyQt5
PyQt5 keyPressEvent 不适用于终止 App Qt Designer
在 macOS 和 Windows 上使用 PyInstaller 编译时,简单的 PyQt5 GUI 看起来像 GTK