[Python]xlrd.biffh.XLRDError: Excel xlsx file; not supported


神奇~~幫幾個同事安裝配置python環境,突然跑着好好的一個腳本就跑不起來了。

workbook = xlrd.open_workbook(bom_path)
  File "C:\Python27\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

可我自己卻好好的,想不通,最后通過pip list檢查了一下自己安裝的庫版本,找到了不同的地方。

我的電腦xlrd版本是1.2.0,給同事他們下載的是新的2.0.1,可能是是版本不兼容導致這個問題

Installing collected packages: xlrd
Successfully installed xlrd-2.0.1
pip list
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Package                       Version
----------------------------- -------
astroid                       1.6.6
backports-abc                 0.5
backports.functools-lru-cache 1.6.1
click                         7.1.2
configparser                  4.0.2
enum34                        1.1.10
et-xmlfile                    1.0.1
futures                       3.3.0
goto-statement                1.2
isort                         4.3.21
jdcal                         1.4.1
lazy-object-proxy             1.5.0
mccabe                        0.6.1
numpy                         1.16.6
openpyxl                      2.6.4
pip                           20.1.1
pylint                        1.9.5
pyzmq                         19.0.1
setuptools                    41.2.0
singledispatch                3.4.0.3
six                           1.15.0
spark-parser                  1.8.9
tornado                       5.1.1
uncompyle                     2.0.0
uncompyle6                    3.7.2
uniout                        0.3.7
wrapt                         1.12.1
xdis                          5.0.1
xlrd                          1.2.0
xlwt                          1.3.0
zmq                           0.0.0

於是嘗試了一下:卸載重新裝舊版本,問題解決 : -):

pip uninstall xlrd
pip install xlrd==1.2.0


免責聲明!

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



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