linux怎么安装openpyxl模块,linux机器上的openpyxl错误

我也有同样的问题。。。在

当我回来的时候,我很奇怪。在

这是密码(注'示例.xlsx'可以是任何填充了A1的电子表格。)import openpyxl

#D

arg1 = "A1"

'''Reads in a sheet'''

wb = openpyxl.load_workbook('example.xlsx')

ws = "".join(wb.get_sheet_names()[0])

sheet_ranges = wb[ws]

print(sheet_ranges[arg1].value)

结果是我们在这条线上失败了:

^{pr2}$

结果是:

TypeError:“Workbook”对象没有属性“getitem”

我怀疑它有一段时间是因为我加了一些魔术线。。。在

以下是一条线索:dir(openpyxl.doc)

['add', 'class', 'contains', 'delattr', 'doc', 'eq', 'format', 'ge', 'getattribute', 'getitem', 'getnewargs', 'getslice', 'gt', 'hash', 'init', 'le', 'len', 'lt', 'mod', 'mul', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'rmod', 'rmul', 'setattr', 'sizeof', 'str', 'subclasshook', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

注意,这里有getitem的文档

塔达

答案是我通过debian存储库加载的openpyxl版本是1.5版。您可以使用以下代码发现这个可怕的事实:''' checks version of openpyxl '''

if str(openpyxl.__version__) <> "2.3.2":

#T if str(openpyxl.__version__) <> "1.5":

print "Trouble Ahead...this machine uses openpyx version "+str(openpyxl.__version__)

else:

print "Good to Go! This this machine uses openpyx openpyx version "+str(openpyxl.__version__)

当前版本是2.3.2。旧版本会让你哭泣。在

燧石

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值