Skip to content

Log File Error Causes failure to terminate in xlwings VBA on macOS. #666

@timvkuijk

Description

@timvkuijk

If I call a Python program using the RunPython method from VBA in Microsoft Excel 2016 for macOS, I get a timeout. This is based, I've found, on the amount of print statements included in the program.

I created a simple enough program to replicate the program. Basically, when the program prints to xlwings_log.txt excessively, it fails in some way. If you look at the xlwings_log.txt file, the print statements are all there, except the file ends in

0
1
2.... (through to)
99999
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: 'module' object is not callable

The xlwings program in VBA will stay running, eventually causing Microsoft Excel to stop responding. At a certain point it will ask you to wait or quit Excel. If you wait, eventually the program terminates and xlwings_log.txt is deleted.

Basically, some error is causing Excel to hand when the file prints enough. If you reduce the print statements to 1000, there doesn't seem to be an issue.

import xlwings as xw

wb=xw.Book.caller()
wb.sheets[0].range('A1').value = 'Hello World'

for i in range(100000):
    print(i)

wb.sheets[0].range('A1').value = 'Hello World-fail to terminate'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions