xlrd.biffh.XLRDError: Excel xlsx file; not supported


今天使用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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM