更新anaconda& python'导入matplotlib.pyplot作为plt'不再起作用

时间:2016-01-22 03:32:10

标签: python matplotlib

我无法使用命令

import matplotlib.pyplot as plt

之前我使用过我的脚本,但由于我使用

更新了我的anaconda,因此它们不再起作用了
conda -update all

我收到一条很长的错误消息,但我真的不明白这是什么问题,请参阅随附的代码。任何人都知道如何解决它?我甚至已经卸下anaconda并重新安装它但它还没有修复它?我也只更新了使用公寓的marplotlib,但它没有帮助。有什么建议吗?

run transform.py
/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273:UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/Users/tfridrich/computing/Log_spectral_analysis/test01/transform.py in <module>()
      6 import scipy.fftpack
      7 #import matplotlib as plt
----> 8 import matplotlib.pyplot as plt
      9 from las import LASReader
     10 import checknumber

/Users/tfridrich/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/tfridrich/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/tfridrich/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/tfridrich/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/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py in <module>()
     13 from matplotlib.path import Path
     14 from matplotlib import rcParams
---> 15 import matplotlib.font_manager as font_manager
     16 from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
     17 from matplotlib.ft2font import LOAD_TARGET_LIGHT

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in <module>()
   1419                 verbose.report("Using fontManager instance from %s" % _fmcache)
   1420         except:
-> 1421             _rebuild()
   1422     else:
   1423         _rebuild()

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in _rebuild()
   1404     def _rebuild():
   1405         global fontManager
-> 1406         fontManager = FontManager()
   1407         if _fmcache:
   1408             pickle_dump(fontManager, _fmcache)

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in __init__(self, size, weight)
   1042         #  Load TrueType fonts and create font dictionary.
   1043 
-> 1044         self.ttffiles = findSystemFonts(paths) + findSystemFonts()
   1045         self.defaultFamily = {
   1046             'ttf': 'Bitstream Vera Sans',

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in findSystemFonts(fontpaths, fontext)
    322                     fontfiles[f] = 1
    323 
--> 324             for f in get_fontconfig_fonts(fontext):
    325                 fontfiles[f] = 1
    326 

/Users/tfridrich/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py in get_fontconfig_fonts(fontext)
    274         pipe = subprocess.Popen(['fc-list', '--format=%{file}\\n'],
    275                                 stdout=subprocess.PIPE,
--> 276                                 stderr=subprocess.PIPE)
    277         output = pipe.communicate()[0]
    278     except (OSError, IOError):

/Users/tfridrich/anaconda/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
    708                                 p2cread, p2cwrite,
    709                                 c2pread, c2pwrite,
--> 710                                 errread, errwrite)
    711         except Exception:
    712             # Preserve original exception in case os.close raises.

/Users/tfridrich/anaconda/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
   1332                     if e.errno != errno.ECHILD:
   1333                         raise
-> 1334                 child_exception = pickle.loads(data)
   1335                 raise child_exception
   1336 

/Users/tfridrich/anaconda/lib/python2.7/pickle.pyc in loads(str)
   1386 def loads(str):
   1387     file = StringIO(str)
-> 1388     return Unpickler(file).load()
   1389 
   1390 # Doctest

/Users/tfridrich/anaconda/lib/python2.7/pickle.pyc in load(self)
    862             while 1:
    863                 key = read(1)
--> 864                 dispatch[key](self)
    865         except _Stop, stopinst:
    866             return stopinst.value

/Users/tfridrich/anaconda/lib/python2.7/pickle.pyc in load_string(self)
    970             if rep.startswith(q):
    971                 if len(rep) < 2 or not rep.endswith(q):
--> 972                     raise ValueError, "insecure string pickle"
    973                 rep = rep[len(q):-len(q)]
    974                 break

ValueError: insecure string pickle

1 个答案:

答案 0 :(得分:3)

将OS X更新为El Capitan后,我遇到了同样的问题。经过大量搜索后,我发现X X不再包含在OS X中(参见https://support.apple.com/en-us/HT201341),您需要安装XQuartz作为替代品(参见http://www.xquartz.org/)。在此之后,我能够成功导入matplotlib.pyplot。