Ipython/pylab/matplotlib安装和初始化错误

Sat*_*rat 5 matplotlib ipython python-2.7 python-3.x anaconda

我在OS X El Captain上安装了matplotlib,anaconda,ipython.但是,即使尝试以所有可能的方式设置环境变量,我也无法启动ipython shell --pylab版本.

这是错误.

ImportError: dlopen(/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: @rpath/libpng16.16.dylib
Referenced from: /Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/_png.so
Reason: Incompatible library version: _png.so requires version 40.0.0 or later, but libpng16.16.dylib provides version 39.0.0
Run Code Online (Sandbox Code Playgroud)

最初,在正常的pip安装matplotlib之后,matplotlib没有显示出来.使用conda install -c conda-forge matplotlib = 1.5.2从'conda'重新安装matplotlib之后 ,我没有收到导入错误pf包找不到但是pylab版本仍无法正常运行.我尝试升级libpng库,并将其安装在/ usr/local中,但后来也没用.我不知道如何在/ anaconda/site-packages/matplotlib文件夹中升级_png.so.我也试过设置libpng.x.dylib库的环境变量我不知道为什么它不起作用或者可能是我没有正确完成它.

以下是完整的屏幕截图,以防必要: -

IPython 5.0.0 -- 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?
Run Code Online (Sandbox Code Playgroud)
ImportError                               Traceback (most recent call last)
/Users/apple/anaconda/lib/python2.7/site-packages/IPython/core/shellapp.pyc in <lambda>(key)
    196         shell = self.shell
    197         if self.pylab:
--> 198             enable = lambda key: shell.enable_pylab(key, import_all=self.pylab_import_all)
    199             key = self.pylab
    200         elif self.matplotlib:

/Users/apple/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_pylab(self, gui, import_all, welcome_message)
     2972         from IPython.core.pylabtools import import_pylab
     2973 
---> 2974         gui, backend = self.enable_matplotlib(gui)
     2975 
     2976         # We want to prevent the loading of pylab to pollute the user's

/Users/apple/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
     2933 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
     2934 
 --->2935         pt.activate_matplotlib(backend)
     2936         pt.configure_inline_support(self, backend)
     2937 

/Users/apple/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in activate_matplotlib(backend)
     293     matplotlib.rcParams['backend'] = backend
     294 
 --> 295     import matplotlib.pyplot
     296     matplotlib.pyplot.switch_backend(backend)
     297 

/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
     27 from cycler import cycler
     28 import matplotlib
 --->29 import matplotlib.colorbar
     30 from matplotlib import style
     31 from matplotlib import _pylab_helpers, interactive

/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
     32 import matplotlib.artist as martist
     33 import matplotlib.cbook as cbook
---> 34 import matplotlib.collections as collections
     35 import matplotlib.colors as colors
     36 import matplotlib.contour as contour

/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/collections.py in <module>()
     25 import matplotlib.artist as artist
     26 from matplotlib.artist import allow_rasterization
---> 27 import matplotlib.backend_bases as backend_bases
     28 import matplotlib.path as mpath
 29 from matplotlib import _path

/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py in <module>()
     60 
     61 import matplotlib.tight_bbox as tight_bbox
---> 62 import matplotlib.textpath as textpath
     63 from matplotlib.path import Path
     64 from matplotlib.cbook import mplDeprecation, warn_deprecated

/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py in <module>()
     16 from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
     17 from matplotlib.ft2font import LOAD_TARGET_LIGHT
---> 18 from matplotlib.mathtext import MathTextParser
     19 import matplotlib.dviread as dviread
     20 from matplotlib.font_manager import FontProperties

/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/mathtext.py in <module>()
     58 
     59 import matplotlib.colors as mcolors
---> 60 import matplotlib._png as _png
     61 ####################
     62 

ImportError: dlopen(/Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/apple/anaconda/lib/python2.7/site-packages/matplotlib/_png.so
  Reason: Incompatible library version: _png.so requires version 40.0.0 or later, but libpng16.16.dylib provides version 39.0.0
Run Code Online (Sandbox Code Playgroud)

Sea*_*ean 1

尝试:

brew uninstall libpng
conda uninstall matplotlib
conda install matplotlib
Run Code Online (Sandbox Code Playgroud)