2017-02-24 16 views
1

私はJupyterでmatplotlibを使ってグラフィックをプロットしようとしていましたが、次に 'pylab inline'だけで次のエラーが表示されました。私はPython 3.xとanacondaを使ってMacBookで作業しています。私は同様の傾向(例:this)といくつかの潜在的な解決策を見つけましたが、うまく機能しませんでした。私はすべてを試みたが、何も働かない。私は本当に助けていただければ幸いです。%pylabインラインエラー "matplotlib/fontList.py3k.cache"

私のコード:

次のエラーが生成さ
%pylab inline 

:私の場合は font_manager.py :

--------------------------------------------------------------------------- 
FileNotFoundError       Traceback (most recent call last) 
//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in <module>() 
    1429   try: 
-> 1430    fontManager = pickle_load(_fmcache) 
    1431    if (not hasattr(fontManager, '_version') or 

//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in pickle_load(filename) 
    965  """ 
--> 966  with open(filename, 'rb') as fh: 
    967   data = pickle.load(fh) 

FileNotFoundError: [Errno 2] No such file or directory: '/Users/sebasg167/.matplotlib/fontList.py3k.cache' 

During handling of the above exception, another exception occurred: 

TypeError         Traceback (most recent call last) 
<ipython-input-2-d4543581fa9d> in <module>() 
----> 1 get_ipython().magic('pylab inline') 

//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s) 
    2156   magic_name, _, magic_arg_s = arg_s.partition(' ') 
    2157   magic_name = magic_name.lstrip(prefilter.ESC_MAGIC) 
-> 2158   return self.run_line_magic(magic_name, magic_arg_s) 
    2159 
    2160  #------------------------------------------------------------------------- 

//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line) 
    2077     kwargs['local_ns'] = sys._getframe(stack_depth).f_locals 
    2078    with self.builtin_trap: 
-> 2079     result = fn(*args,**kwargs) 
    2080    return result 
    2081 

<decorator-gen-105> in pylab(self, line) 

//anaconda/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k) 
    186  # but it's overkill for just that one bit of state. 
    187  def magic_deco(arg): 
--> 188   call = lambda f, *a, **k: f(*a, **k) 
    189 
    190   if callable(arg): 

//anaconda/lib/python3.6/site-packages/IPython/core/magics/pylab.py in pylab(self, line) 
    154    import_all = not args.no_import_all 
    155 
--> 156   gui, backend, clobbered = self.shell.enable_pylab(args.gui, import_all=import_all) 
    157   self._show_matplotlib_backend(args.gui, backend) 
    158   print ("Populating the interactive namespace from numpy and matplotlib") 

//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in enable_pylab(self, gui, import_all, welcome_message) 
    2984   from IPython.core.pylabtools import import_pylab 
    2985 
-> 2986   gui, backend = self.enable_matplotlib(gui) 
    2987 
    2988   # We want to prevent the loading of pylab to pollute the user's 

//anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui) 
    2945     gui, backend = pt.find_gui_and_backend(self.pylab_gui_select) 
    2946 
-> 2947   pt.activate_matplotlib(backend) 
    2948   pt.configure_inline_support(self, backend) 
    2949 

//anaconda/lib/python3.6/site-packages/IPython/core/pylabtools.py in activate_matplotlib(backend) 
    292  matplotlib.rcParams['backend'] = backend 
    293 
--> 294  import matplotlib.pyplot 
    295  matplotlib.pyplot.switch_backend(backend) 
    296 

//anaconda/lib/python3.6/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 

//anaconda/lib/python3.6/site-packages/matplotlib/colorbar.py in <module>() 
    34 import matplotlib.collections as collections 
    35 import matplotlib.colors as colors 
---> 36 import matplotlib.contour as contour 
    37 import matplotlib.cm as cm 
    38 import matplotlib.gridspec as gridspec 

//anaconda/lib/python3.6/site-packages/matplotlib/contour.py in <module>() 
    20 import matplotlib.colors as colors 
    21 import matplotlib.collections as mcoll 
---> 22 import matplotlib.font_manager as font_manager 
    23 import matplotlib.text as text 
    24 import matplotlib.cbook as cbook 

//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in <module>() 
    1438    raise 
    1439   except: 
-> 1440    _rebuild() 
    1441  else: 
    1442   _rebuild() 

//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in _rebuild() 
    1417   global fontManager 
    1418 
-> 1419   fontManager = FontManager() 
    1420 
    1421   if _fmcache: 

//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in __init__(self, size, weight) 
    1071   self.afmfiles = findSystemFonts(paths, fontext='afm') + \ 
    1072    findSystemFonts(fontext='afm') 
-> 1073   self.afmlist = createFontList(self.afmfiles, fontext='afm') 
    1074   if len(self.afmfiles): 
    1075    self.defaultFont['afm'] = self.afmfiles[0] 

//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in createFontList(fontfiles, fontext) 
    589     continue 
    590    try: 
--> 591     prop = afmFontProperty(fpath, font) 
    592    except KeyError: 
    593     continue 

//anaconda/lib/python3.6/site-packages/matplotlib/font_manager.py in afmFontProperty(fontpath, font) 
    498  """ 
    499 
--> 500  name = font.get_familyname() 
    501  fontname = font.get_fontname().lower() 
    502 

//anaconda/lib/python3.6/site-packages/matplotlib/afm.py in get_familyname(self) 
    523   extras = (br'(?i)([ -](regular|plain|italic|oblique|bold|semibold|' 
    524     br'light|ultralight|extra|condensed))+$') 
--> 525   return re.sub(extras, '', name) 
    526 
    527  @property 

//anaconda/lib/python3.6/re.py in sub(pattern, repl, string, count, flags) 
    189  a callable, it's passed the match object and must return 
    190  a replacement string to be used.""" 
--> 191  return _compile(pattern, flags).sub(repl, string, count) 
    192 
    193 def subn(pattern, repl, string, count=0, flags=0): 

TypeError: cannot use a bytes pattern on a string-like object 
+0

[MCVE]問題は完全に無用であるのなしで一人でトレースバックが。[編集]問題。 – ImportanceOfBeingErnest

+0

こんにちはImportanceOfBeingErnestを再現し、最小限の例とあなたの質問には、問題があるしてください、この中問題が非常に基本的な '%pylab inline'から来た場合、同様の傾向で見られるように、問題はfont_manager.pyファイルから来ています。私のコードに関連するものは何もありません。 –

答えて

0

あなたはこのファイルを見つける必要がありますC:\ Users \ユーザーグスタボ\ Anaconda3 \ Lib \ site-packages \ matplotlib \ font_manager.py

とFIND def win32InstalledFonts(directory = None、fontext = 'ttf') とre

デフwin32InstalledFonts(ディレクトリ=なし、fontext =「TTF」):: 「」指定されたフォントディレクトリ内のフォントのための」 検索、または何も与えられない場合 システムディレクトリを使用 によってを配置します。 TrueTypeフォント のファイル名がデフォルトで返されます。fontext == 'afm'の場合、AFMフォントが返されます。 「」」

from six.moves import winreg 
if directory is None: 
    directory = win32FontDirectory() 

fontext = get_fontext_synonyms(fontext) 

key, items = None, {} 
for fontdir in MSFontDirectories: 
    try: 
     local = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, fontdir) 
    except OSError: 
     continue 

    if not local: 
     return list_fonts(directory, fontext) 
    try: 
     for j in range(winreg.QueryInfoKey(local)[1]): 
      try: 
       key, direc, any = winreg.EnumValue(local, j) 
       if not is_string_like(direc): 
        continue 
       if not os.path.dirname(direc): 
        direc = os.path.join(directory, direc) 
        direc = direc.split('\0', 1)[0] 

       if os.path.splitext(direc)[1][1:] in fontext: 
        items[direc] = 1 
      except EnvironmentError: 
       continue 
      except WindowsError: 
       continue 
      except MemoryError: 
       continue 
     return list(six.iterkeys(items)) 
    finally: 
     winreg.CloseKey(local) 
return None 
関連する問題