为什么我没有xlrd?

时间:2015-07-09 22:51:02

标签: python pandas matplotlib pip

我使用pandas安装了matplotlibpip3 install。然后我运行了这个脚本:

import pandas as pd
import matplotlib.pyplot as plt
data = pd.ExcelFile("Obes-phys-acti-diet-eng-2014-tab.xls")
print (data.sheet_names)

并收到此错误:

dhcp-169-233-172-97:Obesity juliushamilton$ python3 ob.py
Traceback (most recent call last):
  File "ob.py", line 4, in <module>
    data = pd.ExcelFile("Obes-phys-acti-diet-eng-2014-tab.xls")
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pandas/io/excel.py", line 169, in __init__
    import xlrd  # throw an ImportError if we need to
ImportError: No module named 'xlrd'

为什么缺少必要的xlrd

2 个答案:

答案 0 :(得分:32)

安装新模块:

pip install xlrd

答案 1 :(得分:21)

&#34;它是一个可选的依赖项pandas.pydata.org/pandas-docs/…您可以单独安装它。&#34; - (bernie,在现已删除的评论中。)