I add matplotlib pyplot to my Project When i run it work seamless but when ı convert my code to exe Thats give me
tuple index out of range
from PyQt5.QtWidgets import QVBoxLayout,QPushButton,QWidget,QApplication
from PyQt5.QtGui import QIcon
import sys
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class MplCanvas(FigureCanvas):
def __init__(self, parent=None, width=50, height=40, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
super(MplCanvas, self).__init__(fig)
class Window(QWidget):
def __init__(self): # Constructor Method
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle("MatPlotLib Live Graph Example")
self.setWindowIcon(QIcon("/images/pp.jpg"))
self.setGeometry(300,300,500,500)
self.mainLayout = QVBoxLayout()
self.setLayout(self.mainLayout)
self.x = [0 , 1 , 2 , 3]
self.y = [0 , 1 , 2 , 3]
# ----------------------------------------------------------------
self.exampleCanvas = MplCanvas(self, width=5, height=4, dpi=100)
self.exampleCanvas.axes.plot(self.x, self.y , label="Legend")
# ----------------------------------------------------------------
self.mainLayout.addWidget(self.exampleCanvas)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
I am writing code bellow for convert my code to exe:
pyinstaller --onefile --noconsole --icon=roboticon.ico --clean .\canvasmatplot.py
but ı take this return.
tuple index out of range
Thank you for your help.
I am using Python --version 3.10 when ı updated my Pytyhon --version at 3.10.4 my problem was solved .