Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Died Kernel #2411

Open
htrivedi123 opened this issue Mar 5, 2024 · 2 comments
Open

Died Kernel #2411

htrivedi123 opened this issue Mar 5, 2024 · 2 comments

Comments

@htrivedi123
Copy link

OS (e.g. Windows 10 or macOS Sierra)

WIndows 11

Versions of xlwings, Excel and Python (e.g. 0.11.8, Office 365, Python 3.7)

Python 3.10 64 bit, xlwings 0.20.08

Describe your issue (incl. Traceback!)

I have script to create pivot tables in excel using xlwings. I get an error saying Kernel died when the code execution reaches to creating pivot table. it runs fine untill the point of creating a cahce. I checked memory usage and somehow at that point memory usage spikes up. the data files are relatively small around 250-600Kb range. Not sure why it the kernel keeps dying. I use Jupyter Notebook and I have tried using spider, PyCharm and was able to replicate same issue in other IDEs.

# Your traceback here

Kernel died

Include a minimal code sample to reproduce the issue (and attach a sample workbook if required!)

for file_name in os.listdir(folder_path):
if file_name.endswith('.xlsx'):
file_path = os.path.join(folder_path,file_name)

        num_files_processed +=1

        app = xw.App(visible=False)
        
        wb =xw.books.open(file_path)

        data_sheet = wb.sheets['Payroll Data']
     
        print("Can Read Payroll data!")
        
        #Define pivot table data range

        num_col = data_sheet.range('A1').end('right').column
        num_row = data_sheet.range('A1').end('down').row
        PivotSourceRange = data_sheet.range((1,1), (num_row,num_col))
        PivotSheetName = wb.sheets['Salaries By Employees']
        PivotTableName = 'Salaries By Employees Table'
        
        pivot_tab_name = PivotSheetName.range("A1")
        
        print("Can define Data Range!")


                    #create pivot table cache

        PivotCache = wb.api.PivotCaches().Create(SourceType=constants.PivotTableSourceType.xlDatabase,
                    SourceData=PivotSourceRange.api,
                    Version=constants.PivotTableVersionList.xlPivotTableVersion14)
        
        print("Cache created successfully!")

        **PivotTable = PivotCache.CreatePivotTable(TableDestination=pivot_tab_name,
                    TableName=PivotTableName,
                    DefaultVersion=constants.PivotTableVersionList.xlPivotTableVersion14)**
@fzumstein
Copy link
Member

can you paste the full traceback?

@htrivedi123
Copy link
Author

@fzumstein - thanks felix for your response. I actually found a solution in other threads. explicitly defnining TableDestination values helped resolve the issue. Thank you again for your time!

  **PivotTable = PivotCache.CreatePivotTable(TableDestination=pivot_tab_name,
                TableName=PivotTableName,
                DefaultVersion=constants.PivotTableVersionList.xlPivotTableVersion14)**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants