Debug Visual Studio Python

I installed Python Tools for Visual Studio. I also installed the latest Anaconda package. I am a .NET developer, but have the need to do some work with spreadsheets using python.

So, I develop and run my python code in Visual Studio with the goal of ultimately calling it excel with xlwings.

I read about inserting "mock caller", so I wrote code like this

if __name__ == '__main__':
    neto = exportcategories_api('Bellbird2')

    ## Expects the Excel file next to this source file, adjust accordingly.
    path = os.path.abspath(os.path.join(os.path.dirname(__file__),
                           'Export Categories.xlsm'))
    xw.Book.set_mock_caller(path)
    neto.export()

I also included:

import xlwings as xw

at the top of my python file. This is underlined with "impossible to solve."

and when I run my code, nothing happens. A command window appears, but it seems to be hanging.

If I delete import xlwings as xwand comment out my lines of code of the calling code, it works fine.

How am I wrong?

+4

Source: https://habr.com/ru/post/1650450/


All Articles