类型错误:Workbook.__init__() 'options' 遇到意外的关键字参数



我收到这个错误

Traceback(上次调用(:文件"C: \Python310\lib\tkinter_init_.py";,第1921行,在调用中返回self.func(*args(File"C: \Users\achille.gouttard\Documents\co协同\11_16_2021\app.py",线861,在selectItem中self.find_match(1(文件";C: \Users\achille.gouttard\Documents\co协同\11_16_2021\app.py",线673,在find_match中使用ExcelWriter(路径,engine="openpyxl",文件"C:\Users\achille.guttard\AppData\Roaming\Python\Python310\site-packages\pandas\io\excel_openpyxl.py";,第72行,在initself.book=工作簿(**engine_kwargs(类型错误:工作簿init((获得了一个意外的关键字参数"options">

来自这行代码:

with ExcelWriter(path, engine="openpyxl",
engine_kwargs={'options': {'strings_to_formulas': False, "strings_to_urls": False}}) as writer:

它过去工作得很好,但有人把我的Python安装搞砸了,当我试图重新安装所有东西时,我遇到了这个错误。

请注意,当我安装软件包时,我收到了以下警告:

警告:脚本styleframe.exe安装在'C:\Users\achille.guttard\AppData\Roaming\Python\Python310\Scripts'其不在PATH上。考虑将此目录添加到PATH中,或者,如果如果要取消显示此警告,请使用--no-warn脚本位置。

找不到与此问题相关的任何内容,因此如果您有任何想法,欢迎您提出。

这是因为引擎openpyxl不支持引擎kwargs。您需要更改engine参数(例如'xlsxwriter'非常适用(。
with pd.ExcelWriter(name, engine='xlsxwriter', engine_kwargs={'options': {'strings_to_numbers': True}}) as writer:
stuff()

还要注意的是,如果您没有xlsxwriter库,您应该手动安装它。

如果没有发动机arg通过,则自动选择发动机。

相关内容

最新更新