python 3.5-> 3.6 Tablib TypeError:cell()缺少1个必需的位置参数:'column'

戴维:

从python 3.5迁移到3.6,我的单元测试发现django-import-export&tablib有问题:

TypeError:cell()缺少1个必需的位置参数:“ column”

File "<path>/lib/python3.6/site-packages/tablib/formats/_xlsx.py", line 122, in dset_sheet
    cell = ws.cell('%s%s' % (col_idx, row_number))
    TypeError: cell() missing 1 required positional argument: 'column'

tablib中的行:

    cell = ws.cell('%s%s' % (col_idx, row_number))

所以确实,该列没有论点

我的查看代码:

my_resource = MyModelResource(queryset=my_queryset)
dataset = my_resource.export()
response = HttpResponse(dataset.xlsx, content_type='application/vnd.ms-excel')

这在python3.5中工作正常,但在3.6下失败

requirements.txt:

...
tablib==0.12.1
django-import-export==0.7.0
Django==1.11.7
...
马丁·彼得斯(Martijn Pieters):

这与Python 3.5或3.6无关。openpyxl与3.5设置相比,您在3.6安装中安装了较新的版本。

在3.6中安装的版本已从方法中删除了不推荐使用的坐标参数,worksheet.cell()使用rowcolumn强制参数这是2018年1月19日发布的2.5.0b1版本的一部分(两周前):

主要变化

worksheet.cell()不再接受坐标参数。现在的语法是ws.cell(row, column, value=None)

磁带tablib库尚未适应此更改。该代码应直接传递列号和行号:

cell = ws.cell(row=row_number, column=col_idx)

使用关键字参数将确保一直到1.1.0(该版本增加了对columnand row参数的支持的版本,于2010年发行)的兼容性

同时,您可以将openpyxl安装降级为版本2.4.9,这是没有这些更改的最新版本。

另请参阅项目存储库中的问题324tablib

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

python decorator TypeError缺少1个必需的位置参数

Python3 Flask-缺少1个必需的位置参数:“ self”

__init __()缺少3个必需的位置参数

为什么n = [1,2,3,4,5,6,7,8],n [:6:-2]在Python中是[8]?

扭曲-Python3 TypeError:__init __()缺少1个必需的位置参数:“ factory”

python缺少1个必需的位置参数

Python3 TypeError:接受1个位置参数,但给定2个

Matplotlib 3D Surface缺少1个必需的位置参数:“ Z”

TypeError:create_superuser()缺少3个必需的位置参数:

TypeError:<lambda>()缺少1个必需的位置参数:使用lambda对python 3字典进行排序时为'count'

需要3到5个位置参数,但给出了6个?

TypeError:wrapper()缺少1个必需的位置参数:'num'(python)

交换以2的[1,2,3,4,5,6] = [2,1,4,3,6,5]分组的相邻元素

更新选择=(选择%6)+ 1从python 2到python 3

如何转换list1中的list = [1,2,[3,4],[5,6],7,[8,9,10]] = [1,2,3,4,5,6,7,8 ,9,10]在python中?

Python TypeError:set()缺少1个必需的位置参数:“ value”

类型错误:overlaps() 缺少 3 个必需的位置参数:“y1”、“x2”和“y2”

缺少 3 个必需的位置参数 Python

必需的位置参数 python3 乌龟

Python Selenium TypeError 期望 3 个参数 (1given)

如何修复 TypeError:__init__() 缺少 3 个必需的位置参数:来自 matplotlib.patches 椭圆的“xy”、“width”和“height”

将 int ([3,6]) 数组转换为 [[1,2,3],[1,2,3,4,5,6]]

在Java中找到1=>5的函数;2=>4;3=>3; 4=>2;5=>1;6=>7;7=>6;

类型错误:request() 缺少 1 个必需的位置参数:urllib3 中的“url”

Python 3 - __init__() 需要 1 到 5 个位置参数,但给出了 6 个

从 web3py 发送原始交易:TypeError: <lambda>() 缺少 4 个必需的位置参数:“hash”、“r”、“s”和“v”

Python 错误 - TypeError: create_or_update() 需要 5 个位置参数,但给出了 6 个

Python:find_element() 需要 1 到 3 个位置参数,但给出了 6 个

Python 中的 WAP 生成以下數列最多 500。#1, 3, 6, 10, 15, 21,... 1+2=3,3+3=6,6+4=10,10+5=15