Attribute Error: 'Workbook' object has no attribute 'active'

有些话、适合烂在心里 提交于 2019-12-13 21:18:37

问题


I am new to both python programming and the raspberry pi environment and I need to do some project with it. As I was trying to run the sample code for the openpyxl library I found myself stuck in the error provided in the title, Attribute Error: 'Workbook' object has no attribute 'active' I tried to install some more packages to check if there are just missing libraries but none of them work

the code I am trying is below:

    from openpyxl import Workbook
    wb = Workbook()
    ws = wb.active
    ws['A1'] = 42
    ws.append([1, 2, 3])
    import datetime
    ws['A2'] = datetime.datetime.now()
    wb.save("sample.xlsx")

how can I get to run it? thanks in advance


回答1:


Check the version of the package you're running as it states that active is a property in the latest version of the documentation.

To discover your current version:

import openpyxl
print(openpyxl.__version__)

You should be able to upgrade your openpyxl version with pip install openpyxl --upgrade to get the latest version.



来源:https://stackoverflow.com/questions/32545454/attribute-error-workbook-object-has-no-attribute-active

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!