今天使用pandas打开.xlsx文件,出现
Traceback (most recent call last):
File “china.py”, line 6, in <module>
posi=pd.read_excel(“2015Cities-CHINA.xlsx”) #▒▒ȡ▒й▒▒▒▒▒▒▒▒▒
File “D:/Python37/lib/site-packages/pandas/util/_decorators.py”, line 296, in wrapper
return func(*args, **kwargs)
File “D:/Python37/lib/site-packages/pandas/io/excel/_base.py”, line 304, in read_excel
io = ExcelFile(io, engine=engine)
File “D:/Python37/lib/site-packages/pandas/io/excel/_base.py”, line 867, in __init__
self._reader = self._engines[engine](self._io)
File “D:/Python37/lib/site-packages/pandas/io/excel/_xlrd.py”, line 22, in __init__
super().__init__(filepath_or_buffer)
File “D:/Python37/lib/site-packages/pandas/io/excel/_base.py”, line 353, in __init__
self.book = self.load_workbook(filepath_or_buffer)
File “D:/Python37/lib/site-packages/pandas/io/excel/_xlrd.py”, line 37, in load_workbook
return open_workbook(filepath_or_buffer)
File “D:/Python37/lib/site-packages/xlrd/__init__.py”, line 170, in open_workbook
raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+’; not supported’)
xlrd.biffh.XLRDError: Excel xlsx file; not supported
问题原因:
安装的 xlrd-2.0.1,该版本只支持.xls文件
使用 pd.read_excel(“2015Cities-CHINA.xlsx”) 报错
解决方法:
卸载当前安装的xlrd
pip uninstall xlrd
安装低版本的xlrd
pip install xlrd==1.2.0
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/20440.html