简体   繁体   English

在Ubuntu 12.04上通过pip安装matplotlib

[英]Installing matplotlib via pip on Ubuntu 12.04

I'm trying to use matplotlib on Ubuntu 12.04. 我正在尝试在Ubuntu 12.04上使用matplotlib。 So I built a wheel with pip: 因此,我用点子制作了一个轮子:

python .local/bin/pip wheel --wheel-dir=wheel/ --build=build/ matplotlib python .local / bin / pip wheel --wheel-dir = wheel / --build = build / matplotlib

Then successfully installed it: 然后成功安装它:

python .local/bin/pip install --user --no-index --find-links=wheel/ --build=build/ matplotlib python .local / bin / pip install --user --no-index --find-links = wheel / --build = build / matplotlib

But when I'm trying to import it in ipython ImportError occures: 但是当我尝试在ipython中导入它时,发生ImportError:

In [1]: import matplotlib 在[1]中:import matplotlib

In [2]: matplotlib.get_backend() 在[2]中:matplotlib.get_backend()
Out[2]: u'agg' 出[2]:u'agg'

In [3]: import matplotlib.pyplot 在[3]中:import matplotlib.pyplot

ImportError ImportError
Traceback (most recent call last) /place/home/yefremat/ in () ----> 1 import matplotlib.pyplot 追溯(最近一次通话)/ place / home / yefremat / in()----> 1 import matplotlib.pyplot

/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/pyplot.py in () 32 from matplotlib import docstring 33 from matplotlib.backend_bases import FigureCanvasBase ---> 34 from matplotlib.figure import Figure, figaspect 35 from matplotlib.gridspec import GridSpec 36 from matplotlib.image import imread as _imread /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/pyplot.py in()32从matplotlib导入docstring 33从matplotlib.backend_bases导入FigureCanvasBase ---> 34从matplotlib.figure导入图,来自matplotlib.gridspec的figaspect 35从matplotlib.image导入的GridSpec 36读为_imread

/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/figure.py in () 38 import matplotlib.colorbar as cbar 39 ---> 40 from matplotlib.axes import Axes, SubplotBase, subplot_class_factory 41 from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput 42 from matplotlib.legend import Legend /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/figure.py in()38 import matplotlib.colorbar as cbar 39 ---> 40 from matplotlib.axes import Axes,SubplotBase,subplot_class_factory 41从matplotlib.blocking_input导入BlockingMouseInput,BlockingKeyMouseInput 42从matplotlib.legend导入图例

/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/ init .py in () 2 unicode_literals) 3 ----> 4 from ._subplots import * 5 from ._axes import * /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/ init .py in()2 unicode_literals)3 ----> 4 from ._subplots import * 5 from ._axes import *

/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/_subplots.py in () 8 from matplotlib import docstring 9 import matplotlib.artist as martist ---> 10 from matplotlib.axes._axes import Axes 11 12 import warnings /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/_subplots.py in()中8从matplotlib导入docstring 9导入matplotlib.artist作为martist ---> 10从matplotlib.axes导入。 _axes导入轴11 12导入警告

/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/_axes.py in () 36 import matplotlib.ticker as mticker 37 import matplotlib.transforms as mtransforms ---> 38 import matplotlib.tri as mtri 39 import matplotlib.transforms as mtrans 40 from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/_axes.py in()36导入matplotlib.ticker为mticker 37导入matplotlib.transforms为mtransforms ---> 38导入matplotlib。 Tri as mtri 39 import matplotlib.transforms from matplotlib.container as mtrans 40 import BarContainer,ErrorbarContainer,StemContainer

/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/tri/ init .py in () 7 import six 8 ----> 9 from .triangulation import * 10 from .tricontour import * 11 from .tritools import * /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/tri/ init .py in()7导入六个8 ----> 9从.triangulation导入* 10从.tricontour导入* 11来自.tritools import *

/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/tri/triangulation.py in () 4 import six 5 ----> 6 import matplotlib._tri as _tri 7 import matplotlib._qhull as _qhull 8 import numpy as np /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/tri/triangulation.py in()4导入六个5 ----> 6导入matplotlib._tri为_tri 7导入matplotlib._qhull为_qhull 8将numpy导入为np

ImportError: /home/yefremat/.local/lib/python2.7/site-packages/matplotlib/_tri.so: undefined symbol: _ZNSt8__detail15_List_node_base9_M_unhookEv ImportError:/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/_tri.so:未定义符号:_ZNSt8__detail15_List_node_base9_M_unhookEv

May be I'm doing somethig wrong? 可能是我做错了什么吗? Or may be there is a way to turn off gui support of matplotlib? 还是有办法关闭对matplotlib的gui支持?

Thanks in advance. 提前致谢。

Okay, the problem was in gcc version. 好的,问题出在gcc版本中。 During building and creating wheel of package pip uses system gcc (which version is 4.7.2). 在构建和创建软件包包的过程中,pip使用系统gcc(版本为4.7.2)。 I'm using python from virtualenv, which was built with gcc 4.4.3. 我正在使用来自virtualenv的python,它是由gcc 4.4.3构建的。 So version of libstdc++ library is different in IPython and one that pip used. 因此,libstdc ++库的版本在IPython中与pip使用的库不同。

As always there are two solutions (or even more): pass LD_PRELOAD environment variable with correct libstdc++ before entering IPython or to use same version of gcc during creating wheel and building virtualenv. 与往常一样,有两种解决方案(甚至更多):在进入IPython之前,使用正确的libstdc ++传递LD_PRELOAD环境变量,或者在创建wheel和构建virtualenv时使用相同版本的gcc。 I prefred the last one. 我喜欢最后一个。

Thank you all. 谢谢你们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM