Matplotlib in pyqt5 plot when ı convert .exe return IndexError: tuple index out of range
Matplotlib in pyqt5 plot when ı convert .exe return IndexError: tuple index out of range
我将 matplotlib pyplot 添加到我的项目中当我 运行 它可以无缝工作但是当我将我的代码转换为 exe 时
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_())
我正在编写下面的代码以将我的代码转换为 exe:
pyinstaller --onefile --noconsole --icon=roboticon.ico --clean .\canvasmatplot.py
但我接受了这个 return。
tuple index out of range
感谢您的帮助。
我正在使用 Python --version 3.10 然后我将我的 Python --version 更新为 3.10.4 我的问题已经解决了。
我将 matplotlib pyplot 添加到我的项目中当我 运行 它可以无缝工作但是当我将我的代码转换为 exe 时
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_())
我正在编写下面的代码以将我的代码转换为 exe:
pyinstaller --onefile --noconsole --icon=roboticon.ico --clean .\canvasmatplot.py
但我接受了这个 return。
tuple index out of range
感谢您的帮助。
我正在使用 Python --version 3.10 然后我将我的 Python --version 更新为 3.10.4 我的问题已经解决了。