我已经在我的主目录中成功安装并调用了matplotlib。
[myname@sysimm51 ~]$ python
Python 2.7.6 (default, Nov 11 2013, 13:13:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
>>> import matplotlib
>>> print matplotlib.__file__
/home/myname/lib/python2.7/site-packages/matplotlib/__init__.pyc
但是当我尝试调用pylab(我的代码需要)时,它给了我以下ImportError。我该如何处理?
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myname/lib/python2.7/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/home/myname/lib/python2.7/site-packages/matplotlib/pylab.py", line 226, in <module>
import matplotlib.finance
File "/home/myname/lib/python2.7/site-packages/matplotlib/finance.py", line 21, in <module>
from matplotlib.dates import date2num
File "/home/myname/lib/python2.7/site-packages/matplotlib/dates.py", line 130, in <module>
import matplotlib.ticker as ticker
File "/home/myname/lib/python2.7/site-packages/matplotlib/ticker.py", line 132, in <module>
from matplotlib import transforms as mtransforms
File "/home/myname/lib/python2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: /home/myname/lib/python2.7/site-packages/matplotlib/_path.so: undefined symbol: _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
更新
使用python --pylab
我得到了这个:
$ ipython --pylab
Python 2.7.6 (default, Nov 11 2013, 13:13:15)
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] WARNING | Eventloop or matplotlib integration failed. Is matplotlib installed?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/myname/lib/python2.7/site-packages/ipython-1.2.1-py2.7.egg/IPython/core/shellapp.pyc in <lambda>(key)
221 shell = self.shell
222 if self.pylab:
--> 223 enable = lambda key: shell.enable_pylab(key, import_all=self.pylab_import_all)
224 key = self.pylab
225 elif self.matplotlib:
/home/myname/lib/python2.7/site-packages/ipython-1.2.1-py2.7.egg/IPython/core/interactiveshell.pyc in enable_pylab(self, gui, import_all, welcome_message)
2917 from IPython.core.pylabtools import import_pylab
2918
-> 2919 gui, backend = self.enable_matplotlib(gui)
2920
2921 # We want to prevent the loading of pylab to pollute the user's
/home/myname/lib/python2.7/site-packages/ipython-1.2.1-py2.7.egg/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
2878 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
2879
-> 2880 pt.activate_matplotlib(backend)
2881 pt.configure_inline_support(self, backend)
2882
/home/myname/lib/python2.7/site-packages/ipython-1.2.1-py2.7.egg/IPython/core/pylabtools.pyc in activate_matplotlib(backend)
244 matplotlib.rcParams['backend'] = backend
245
--> 246 import matplotlib.pyplot
247 matplotlib.pyplot.switch_backend(backend)
248
/home/myname/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/pyplot.py in <module>()
22
23 import matplotlib
---> 24 import matplotlib.colorbar
25 from matplotlib import _pylab_helpers, interactive
26 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
/home/myname/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.py in <module>()
25
26 import matplotlib as mpl
---> 27 import matplotlib.artist as martist
28 import matplotlib.cbook as cbook
29 import matplotlib.collections as collections
/home/myname/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/artist.py in <module>()
6 import matplotlib.cbook as cbook
7 from matplotlib import docstring, rcParams
----> 8 from transforms import Bbox, IdentityTransform, TransformedBbox, \
9 TransformedPath, Transform
10 from path import Path
/home/myname/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/transforms.py in <module>()
33 import numpy as np
34 from numpy import ma
---> 35 from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
36 update_path_extents)
37 from numpy.linalg import inv
ImportError: /home/myname/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/_path.so: undefined symbol: _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l