python3 readexcel pandas问题,无法在pandas中读取Excel文件

我正在使用Juypter,我从同一个目录启动,其中包含笔记本和Excel文件。我使用以下命令:import pandas as pd

!ls # Returns the contents of the working directory. Use "dir" in a Windows.

返回:

图书1.xlsx

通用excel_任务.ipynb在

然后使用以下命令:

^{pr2}$

但我得到了以下错误:---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

in

1 excel_file = 'Book1.xlsx'

----> 2 df1 = pd.read_excel(excel_file)

/usr/local/lib/python3.7/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)

206 else:

207 kwargs[new_arg_name] = new_arg_value

--> 208 return func(*args, **kwargs)

209

210 return wrapper

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, verbose, parse_dates, date_parser, thousands, comment, skip_footer, skipfooter, convert_float, mangle_dupe_cols, **kwds)

308

309 if not isinstance(io, ExcelFile):

--> 310 io = ExcelFile(io, engine=engine)

311 elif engine and engine != io.engine:

312 raise ValueError(

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_base.py in __init__(self, io, engine)

817 self._io = _stringify_path(io)

818

--> 819 self._reader = self._engines[engine](self._io)

820

821 def __fspath__(self):

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_xlrd.py in __init__(self, filepath_or_buffer)

18 """

19 err_msg = "Install xlrd >= 1.0.0 for Excel support"

---> 20 import_optional_dependency("xlrd", extra=err_msg)

21 super().__init__(filepath_or_buffer)

22

/usr/local/lib/python3.7/site-packages/pandas/compat/_optional.py in import_optional_dependency(name, extra, raise_on_missing, on_version)

91 except ImportError:

92 if raise_on_missing:

---> 93 raise ImportError(message.format(name=name, extra=extra)) from None

94 else:

95 return None

ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值