Python 为什么我没有xlrd?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31329627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 09:49:34  来源:igfitidea点击:

Why don't I have xlrd?

pythonpandasmatplotlibpip

提问by jukhamil

I installed pandasand matplotlibusing pip3 install. I then ran this script:

我安装pandasmatplotlib使用pip3 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)

and received this error:

并收到此错误:

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'

Why is the necessary xlrdmissing?

为什么必要的xlrd缺失?

回答by Rob?

"It's an optional dependency pandas.pydata.org/pandas-docs/…You can install it separately." -- (bernie, in a now-deleted commented.)

“这是一个可选的依赖pandas.pydata.org/pandas-docs/……你可以单独安装它。” --(伯尼,在现已删除的评论中。)

回答by Arthur D. Howland

Install the new module:

安装新模块:

pip install xlrd