无法使用 Matplotlib - Ubuntu 10.10 和 Python 3.2
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 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.
无需 apt-get 即可安装 libpng
或
Install the libpng without apt-get
or