[Python] It runs, but 0xc0000409 error occurs during operation

Discussão em 'Python' iniciado por Stack, Março 9, 2025.

  1. Stack

    Stack Membro Participativo

    I'm practicing a program that reads and displays Excel files Try raising the entire code. I'm using Python 3.9, Pycharm, PyQt5 - 5.15.7

    import sys
    from PyQt5.QtWidgets import QApplication, QWidget, QTableWidget, QTableWidgetItem, QHeaderView, QHBoxLayout, QVBoxLayout, QPushButton
    from PyQt5.QtCore import Qt
    import pandas as pd
    from pympler import muppy
    all_objects = muppy.get_objects()

    class MyApp(QWidget):
    def __init__(self):
    super().__init__()
    self.window_width, self.window_height = 700, 500
    self.resize(self.window_width, self.window_height)

    layout = QVBoxLayout()
    self.setLayout(layout)

    self.table = QTableWidget()
    layout.addWidget(self.table)

    self.button = QPushButton('&load Data')
    self.button.clicked.connect(lambda _, xl_path=excel_file_patch, sheet_name=worksheet_name: self.loadExcelData(xl_path, sheet_name))
    layout.addWidget(self.button)

    def loadExcelData(self, excel_file_dir, worksheet_name):
    df = pd.read_excel(excel_file_dir, worksheet_name)
    if df.size == 0:
    return super.loadExcelData(excel_file_dir, worksheet_name)

    df.fillna('', inplace=True)
    self.table.setRowCount(df.shape[0])
    self.table.setColumnCount(df.shape[0])
    self.table.setHorizontalHeaderLabels(df.columns)

    if __name__ == '__main__':

    excel_file_patch = 'data.xlsx'
    worksheet_name = 'Sales'

    app = QApplication(sys.argv)
    myApp = MyApp()
    myApp.show()

    try:
    sys.exit(app.exec())
    except SystemExit:
    print('closing Window...')

    Continue reading...

Compartilhe esta Página