无法使用 Matplotlib - Ubuntu 10.10 和 Python 3.2

发布于 2024-12-08 19:29:38 字数 2060 浏览 0 评论 0原文

我在 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 中单独导入 matplotlib 时,一切正常,只有当我导入诸如 import matplotlib.pyplot as plt 之类的东西时,我才会看到所有这些错误。

不知道我是否以错误的方式安装了它,或者我是否做错了什么,但这就是我在这里发帖的原因。

谢谢。

I am running python3.2 on Ubuntu 10.10 i386 (32 bit).

I just installed matplotlib-py3 (from source) for learning purposes and when I try one of the many examples on the website:

##!/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^')

In the terminal I get a lot of errors when it's importing 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

I tried with a couple of examples from the website and they all give the same errors. When I import matplotlib by itself in the interactive python shell everything works fine, it's only when I import things like import matplotlib.pyplot as plt that I see all these errors.

Don't know if I installed it the wrong way or if I'm doing something wrong, but that's why I'm posting here.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

佼人 2024-12-15 19:29:38

您的 libpng 未正确安装。很难确切地说出了什么问题,但要么你没有安装这些库,要么是它的开发头文件(但我怀疑 matplotlib 安装会失败),或者也许 matplotlib 假设了库的某些位置。他们迁移到 Ubuntu 10.10。允许同一台计算机上使用 32 位和 64 位库,因此如果 matplotlib 假定某个位置,则在 10.10 上会失败。

Your libpng is not installed correctly. It's hard to say exactly what is wrong, but either you haven't installed those libraries or it's development headers (but I suspect that matplotlib installation then would have failed), or perhaps matplotlib assumes certain locations for the libraries. They moved in Ubuntu 10.10. to allow for 32 and 64 bit libraries on the same machine, so if matplotlib assumes a certain location that would fail on 10.10.

放飞的风筝 2024-12-15 19:29:38

无需 apt-get 即可安装 libpng

wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.4.tar.gz?download
tar xzf libpng-1.5.4.tar.gz
./configure --prefix=/usr/local/libpng

./configure

make
sudo make install

Install the libpng without apt-get

wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.4.tar.gz?download
tar xzf libpng-1.5.4.tar.gz
./configure --prefix=/usr/local/libpng

or

./configure

make
sudo make install
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文