【问题标题】:Unable to use Matplotlib - Ubuntu 10.10 and Python 3.2无法使用 Matplotlib - Ubuntu 10.10 和 Python 3.2
【发布时间】:2023-04-07 21:29:01
【问题描述】:

我在 Ubuntu 10.10 i386(32 位)上运行 python3.2。

我刚刚安装了matplotlib-py3(来自源代码)用于学习目的,当我尝试网站上的众多示例之一时:

##!/usr/local/bin/python3.2
#-*- coding:utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt

# evenly sampled time at 200ms intervals
t = np.arange(0., 5., 0.2)

# red dashes, blue squares and green triangles
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')

在终端中导入 matplotlib 时出现很多错误:

  File "test.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "/usr/local/lib/python3.2/site-packages/matplotlib/pyplot.py", line 24, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/usr/local/lib/python3.2/site-packages/matplotlib/figure.py", line 19, in <module>
    from .axes import Axes, SubplotBase, subplot_class_factory
  File "/usr/local/lib/python3.2/site-packages/matplotlib/axes.py", line 16, in <module>
    import matplotlib.axis as maxis
  File "/usr/local/lib/python3.2/site-packages/matplotlib/axis.py", line 14, in <module>
    import matplotlib.text as mtext
  File "/usr/local/lib/python3.2/site-packages/matplotlib/text.py", line 29, in <module>
    from matplotlib.backend_bases import RendererBase
  File "/usr/local/lib/python3.2/site-packages/matplotlib/backend_bases.py", line 47, in <module>
    import matplotlib.textpath as textpath
  File "/usr/local/lib/python3.2/site-packages/matplotlib/textpath.py", line 11, in <module>
    from matplotlib.mathtext import MathTextParser
  File "/usr/local/lib/python3.2/site-packages/matplotlib/mathtext.py", line 60, in <module>
    import matplotlib._png as _png
ImportError: libpng15.so.15: cannot open shared object file: No such file or directory

我尝试了网站上的几个示例,它们都给出了相同的错误。当我在交互式 python shell 中单独 import matplotlib 时,一切正常,只有当我导入 import matplotlib.pyplot as plt 之类的东西时,我才会看到所有这些错误。

不知道是我安装错了还是我做错了什么,但这就是我在这里发帖的原因。

谢谢。

【问题讨论】:

    标签:
    python-3.x
    matplotlib