【发布时间】:2017-02-28 10:27:37
【问题描述】:
我在 ubuntu 16.04 上的 python 2.7.1 上运行 matplotlib 版本 1.5.1。 当我尝试从 matplotlib cbook 模块获取一些示例数据时,它会出现以下错误:
IOError: [Errno 2] No such file or directory: u'/usr/lib/python2.7/dist-packages/matplotlib/mpl-data/sample_data/msft.csv'
MWE 如下:
import matplotlib
import matplotlib.cbook as cbook
print(matplotlib.__version__) # 1.5.1
fname = cbook.get_sample_data('msft.csv', asfileobj=False)
with open(fname,'r') as f:
read_data = f.read()
示例取自:
http://nullege.com/codes/search/matplotlib.cbook.get_sample_data
注意:我还查找了错误报告。
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691960
但是,我想不出解决方案。
所以,问题仍然是我们如何从 matplotlib.cbook 模块导入一些示例 csv 文件(或者,可能是其他一些 png 文件)?
部分链接:
http://matplotlib.org/1.3.1/api/cbook_api.html
How to center a plotted image?
【问题讨论】:
-
你不使用 anaconda 吗?
-
@yugi,不,我使用的是普通 python。
-
您是否检查过该 csv 文件是否确实存在于那里?
标签: python matplotlib ubuntu-16.04