Traceback (most recent call last):
File "main.py", line 25, in
result = pd.read_excel('./pdfdata1.xlsx')
File "D:\Python\lib\site-packages\pandas\util\_decorators.py", line 296, in wrapper
return func(*args, **kwargs)
File "D:\Python\lib\site-packages\pandas\io\excel\_base.py", line 304, in read_excel
io = ExcelFile(io, engine=engine)
File "D:\Python\lib\site-packages\pandas\io\excel\_base.py", line 867, in __init__
self._reader = self._engines[engine](self._io)
File "D:\Python\lib\site-packages\pandas\io\excel\_xlrd.py", line 21, in __init__
import_optional_dependency("xlrd", extra=err_msg)
File "D:\Python\lib\site-packages\pandas\compat\_optional.py", line 110, in import_optional_dependency
raise ImportError(msg) from None
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
使用pandas.read_excel()函数读取xlsx文件里的数据,却报错ImportError: Missing optional dependency ‘xlrd’. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
执行命令 pip install xlrd 安装相应的安装包
pip install xlrd
执行命令 pip install openpyxl 安装相应的安装包
pip install openpyxl
使用openpyxl代替xlrd,读取文件时记得指定引擎engine=‘openpyxl’
result = pd.read_excel('./pdfdata1.xlsx', engine='openpyxl')
正常读取,不再报错!
我的博客,欢迎交流!
我的CSDN博客,欢迎交流!
微信小程序专栏
前端笔记专栏
微信小程序实现部分高德地图功能的DEMO下载
微信小程序实现MUI的部分效果的DEMO下载
微信小程序实现MUI的GIT项目地址
微信小程序实例列表
前端笔记列表
游戏列表