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

时间:2016-07-25 09:48:09

标签: python-2.7 python-3.x matplotlib ipython 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

最初,在正常的 pip install matplotlib 之后,matplotlib没有显示出来。重新安装来自' conda'的matplotlib后运用     conda install -c conda-forge matplotlib = 1.5.2 ,我没有得到导入错误pf包找不到但是pylab版本仍然没有用。我尝试升级libpng库,并将其安装在/ usr / local中,但后来也没用。我不知道_png.so是如何升级的 在/ anaconda / site-packages / matplotlib文件夹中。 我也尝试过设置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?
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

1 个答案:

答案 0 :(得分:1)

尝试:

    class GMSTestViewController: BaseViewController, GMSMapViewDelegate {

        @IBOutlet weak var mapView: GMSMapView!

        let locationManager = CLLocationManager()
        var manager:CLLocationManager!

        override func viewDidLoad() {
            super.viewDidLoad()

            //Setup Location Manager
            manager = CLLocationManager()
            manager.delegate = self
            manager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
            manager.requestAlwaysAuthorization()
            manager.startUpdatingLocation()

            //Map type
            mapView.mapType = kGMSTypeTerrain
        }

        override func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
            let userLocation = locations.last
            let center = CLLocationCoordinate2D(latitude: userLocation!.coordinate.latitude, longitude: userLocation!.coordinate.longitude)

            let camera = GMSCameraPosition.cameraWithLatitude(userLocation!.coordinate.latitude,
                                                              longitude: userLocation!.coordinate.longitude, zoom: 8)
            let mapView = GMSMapView.mapWithFrame(.zero, camera: camera)
            mapView.myLocationEnabled = true
            self.view = mapView

            let marker = GMSMarker()
            marker.position = center
            marker.title = "Current Location"
            marker.snippet = "XXX"
            marker.map = mapView

            locationManager.stopUpdatingLocation()
        }

    }