使用Pandas读取Excel文件报错:BookView.__init__()遇意外参数'WindowWidth'
解决Pandas读取Excel时
BookView.__init__() got an unexpected keyword argument 'WindowWidth'错误 这个错误是由于pandas与openpyxl版本不兼容导致的:openpyxl在新版本中移除了WindowWidth参数,但旧版pandas仍会尝试传递该参数。以下是几种可行的解决办法:
升级pandas到兼容版本
执行命令更新pandas,使其适配新版openpyxl的API:pip install --upgrade pandas降级openpyxl至支持该参数的旧版本
如果不想升级pandas,可安装兼容的openpyxl旧版本,比如3.0.10:pip install openpyxl==3.0.10更换Excel读取引擎
读取文件时指定其他兼容的引擎:- 若文件为
.xls格式,使用xlrd引擎(需先确保安装xlrd:pip install xlrd):arquivo = pd.read_excel(path, engine='xlrd') - 若文件为
.xlsx格式,可尝试pyxlsb引擎(先安装:pip install pyxlsb):arquivo = pd.read_excel(path, engine='pyxlsb')
- 若文件为
内容的提问来源于stack exchange,提问作者Vinicius
相关产品推荐
相关产品推荐

