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
Why don't I have xlrd?
提问by jukhamil
I installed pandas
and matplotlib
using pip3 install
. I then ran this script:
我安装pandas
并matplotlib
使用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 xlrd
missing?
为什么必要的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