简体   繁体   中英

pyinstaller does not work with with pyqt5 and matplotlib

im using pyqt5 to create a gui and using matplotlib

but whene i try to create executable with pyinstaller it dose not work

i try a few solution like :

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

i try to do it with cx_Freeze and try this solution cx_Freeze error: baseline image directory does not exist

but nothing work with me

this is my log after using 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

You can try and downgrade your matplotlib version, which you don't seem to mention. 3.1.3 fixed it in my case using PyInstaller and PyQt5.

solved thanks to @LittleFoxyFox and here is another way with cx_Freeze

in the import area add

import PIL
import tkinter
from tkinter import filedialog

and change backend_qt4agg to backend_qt5aggb in

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)

from cx_Freeze import setup, Executable

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

downgrade PyQt to 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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