module 'xlwings' has no attribute 'Book'

9.8k views Asked by At

I'm trying to use xlwings for the first time but I can't quite understand the documentation. From the section "Quickstart" I read

import xlwings as xw       

wb = xw.Book()  # this will create a new workbook    

When I try this "at home", I have no problem importing xlwings but with the second script I get this error:

AttributeError: module 'xlwings' has no attribute 'Book'

When I try to see the attributes of xw I can see AboveBelow,ActionTime etc. but not Book.

Can you help please?

Thank you very much.

3

There are 3 answers

2
Jatin Tek On

I had the error also and changed from Workbook to Book. It is a version issue.

wb = xw.Workbook()

0
Swaroop Patil On

This fixed the issue for me:

import xlwings as xw
wb = xw.book()

I opened the excel file and seen book written as Book(first capital letter), so I changed it in the code as below:

import xlwings as xw
wb = xw.Book()
0
David On

I had the same issue... in my case it was the name of the file I used: "xlwings.py" Do NOT use that name for the file or the containing folder or you'll get an error.