【问题标题】:Matplotlib.cbook: Can not import matplotlib.cookbook example csv filesMatplotlib.cbook:无法导入 matplotlib.cookbook 示例 csv 文件
【发布时间】: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


【解决方案1】:

将 xlrd 与 matplotlib 一起用于 csv 文件......它工作得非常好

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-18
    • 2019-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-25
    • 1970-01-01
    相关资源
    最近更新 更多