i'm trying to compile python application using pyinstaller. This application import Pyside and Matplotlib, on a windows32 Note that without pyinstaller the application works.
I have reduce the application to point the problem.
Here my class using matplotlib :
import matplotlib as plt
plt.use('Qt4Agg')
plt.rcParams['backend.qt4'] = 'PySide'
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
from matplotlib.figure import Figure
import PySide.QtGui as QtGui
import PySide
class MatplotlibWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(MatplotlibWidget, self).__init__(parent)
self.figure = Figure(facecolor='white')
self.canvas = FigureCanvasQTAgg(self.figure)
def main():
import sys
app = PySide.QtGui.QApplication(sys.argv)
MatplotlibWidget(PySide.QtGui.QWidget())
sys.exit(app.exec_())
I compiling using this spec file :
# -*- mode: python -*-
block_cipher = None
a = Analysis(['uis/consoresidentielWindow.py'],
pathex=['./src/', './uis/', 'C:\\Users\\jcare\\Desktop\\TestInstall'],
binaries=[],
datas=[('./assets/datas/*', 'assets/datas'),('./assets/icons/*', 'assets/icons'),('./assets/video/*', 'assets/video')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='consoresidentielWindow',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='consoresidentielWindow')
this throw me this traceback :
Traceback <most recent call last>:
File "matplotWidget.py", line 110, in <module>
File "matplotWidget.py", line 105, in main
File "matplotWidget.py", line 25, in __init__
File "site-packages\matplotlib\backends\backend_qt4agg.py.py", line 76, in __init__
File "site-packages\matplotlib\backends\backend_qt4.py.py", line 66, in __init__
TypeError: __init__() missing 1 required positional argument: 'figure'
Failed to execute script matplotWidget
I dond't unterstand why this crash. when i print PySide.QtGui.version, that good : 4.8.7 Probably a hook problem ? but i do not find the good library to hook. If somoene have an idea. Thanks
Few Research : I identify the problem :
plt.use('Qt4Agg')
plt.rcPArams['backend.qt4'] = 'PySide'
Do not work with pyinstaller. I have no idea how fix it
Few Search later :
The problem is not plt.use('Qt4Agg') and plt.rcPArams['backend.qt4'] = 'PySide'
When i print they values, they are fine. That point that again a problem of includes or something like that.