导入

时间:2015-12-14 21:43:09

标签: python python-2.7 matplotlib

我正在使用OSX El Capitan并尝试导入matplotlib.pyplot

当我这样做时,我得到递归错误,最后它说" ValueError:不安全的字符串pickle"

以下是整个日志:

  

----------------------------------------------- ---------------------------- ValueError Traceback(最近一次调用   最后)in()         4个统计数据=统计数据(" HumanData.xlsx")         五   ----> 6 get_ipython()。magic(u' matplotlib inline')         7         8 #matplotlib.pyplot.hist(stats.getActionData(" Human"," Pacman"," Left")

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc   in magic(self,arg_s)2334 magic_name,_,magic_arg_s =   arg_s.partition('')2335 magic_name =   magic_name.lstrip(prefilter.ESC_MAGIC)    - > 2336返回self.run_line_magic(magic_name,magic_arg_s)2337 2338

     

----------------------------------------------- --------------------------

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc   在run_line_magic(self,magic_name,line)2255
  kwargs [' local_ns'] = sys._getframe(stack_depth).f_locals 2256
  与self.builtin_trap:    - > 2257 result = fn(* args,** kwargs)2258返回结果2259

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc   在matplotlib(自我,行)

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc   in(f,* a,** k)       191#但这只是一点状态的过度杀戮。       192 def magic_deco(arg):    - > 193 call = lambda f,* a,** k:f(* a,** k)       194       195 if callable(arg):

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc   在matplotlib(自我,行)        98打印("可用的matplotlib后端:%s"%backends_list)        99其他:    - > 100 gui,backend = self.shell.enable_matplotlib(args.gui)       101 self._show_matplotlib_backend(args.gui,backend)       102

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc   在enable_matplotlib(self,gui)3130 gui,backend =   pt.find_gui_and_backend(self.pylab_gui_select)3131    - > 3132 pt.activate_matplotlib(后端)3133 pt.configure_inline_support(self,backend)3134

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc   在activate_matplotlib(后端)       272 matplotlib.rcParams [' backend'] =后端       273    - > 274导入matplotlib.pyplot       275 matplotlib.pyplot.switch_backend(后端)       276

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py   in()        27来自cycler import cycler        28导入matplotlib   ---> 29导入matplotlib.colorbar        30来自matplotlib的进口风格        31来自matplotlib import _pylab_helpers,交互式

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py   in()        32导入matplotlib.artist作为martist        33导入matplotlib.cbook作为cbook   ---> 34将matplotlib.collections导入为集合        35导入matplotlib.colors作为颜色        36将matplotlib.contour导入为轮廓

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/collections.py   in()        25导入matplotlib.artist作为艺术家        26来自matplotlib.artist import allow_rasterization   ---> 27将matplotlib.backend_bases导入为backend_bases        28将matplotlib.path导入为mpath        29来自matplotlib import _path

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py   in()        60        61将matplotlib.tight_bbox导入为tight_bbox   ---> 62将matplotlib.textpath导入为textpath        63来自matplotlib.path导入路径        64来自matplotlib.cbook import mplDeprecation,warn_deprecated

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py   in()        13来自matplotlib.path导入路径        14来自matplotlib import rcParams   ---> 15将matplotlib.font_manager导入为font_manager        16来自matplotlib.ft2font导入FT2Font,KERNING_DEFAULT,LOAD_NO_HINTING        17来自matplotlib.ft2font导入LOAD_TARGET_LIGHT

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py   in()1418 verbose.report(" Using   来自%s"的fontManager实例%_fmcache)1419除外:    - > 1420 _rebuild()1421 else:1422 _rebuild()

     

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

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py   在 init (自我,大小,重量)1041#加载TrueType字体   并创建字体字典。 1042    - > 1043 self.ttffiles = findSystemFonts(paths)+ findSystemFonts()1044 self.defaultFamily = {1045
  ' ttf':' Bitstream Vera Sans',

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py   在findSystemFonts(fontpaths,fontext)中       321 fontfiles [f] = 1       322    - > get_fontconfig_fonts(fontext)中的f为323:       324 fontfiles [f] = 1       325

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py   在get_fontconfig_fonts(fontext)中       273 pipe = subprocess.Popen([' fc-list',' - format =%{file} \ n'],       274 stdout = subprocess.PIPE,    - > 275 stderr = subprocess.PIPE)       276输出= pipe.communicate()[0]       277除外(OSError,IOError):

     

/Users/AhmedKhalifa/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除了异常:       712#在os.close提升的情况下保留原始异常。

     

/Users/AhmedKhalifa/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
  如果e.errno!= errno.ECHILD:1333加注    - > 1334 child_exception = pickle.loads(data)1335 raise child_exception 1336

     

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

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/pickle.pyc in load(self)       862而1:       863 key = read(1)    - > 864 dispatchkey       865除了_Stop,stopinst:       866返回stopinst.value

     

/Users/AhmedKhalifa/anaconda/lib/python2.7/pickle.pyc in   LOAD_STRING(个体经营)       970如果rep.startswith(q):       如果len(rep)< 971 2或不回复(q):    - > 972引发ValueError,"不安全的字符串pickle"       973 rep = rep [len(q): - len(q)]       974休息

     

ValueError:不安全的字符串pickle

有任何帮助吗?

1 个答案:

答案 0 :(得分:0)

我有完全相同的问题。我不确定问题是什么,但每隔一段时间,当尝试在ipython中导入matplotlib时遇到此错误并重新启动计算机解决了问题。也许这有助于找到问题?