cannot import workbook in openpyxl

断了今生、忘了曾经 提交于 2019-11-28 01:38:36

I think you want:

from openpyxl import workbook # not Workbook

Note the capitalization of the name here.

franzlorenzon

I answer your second problem, because I found the solution (as though the cause of the first one is the same).

I think the problem is caused because the version that you have installed on your Ubuntu is not the latest version (1.5.7 at the moment). And the official documentation is based on the latest one.

For example the version of openpyxl provided on my Ubuntu 11.10 is not the latest, but 1.5.3, and if you use this syntax (taken from here: https://bitbucket.org/ericgazoni/openpyxl/wiki/Home), the commands work:

from openpyl.workbook import Workbook

for the Workbook and for load_workbook:

from openpyxl.reader.excel import load_workbook

But you can also install the latest one with easy_install:

$ sudo easy_install openpyxl

And to install easy_install, read this answer: https://askubuntu.com/questions/27519/can-i-use-easy-install

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