Skip to content

UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 20: ordinal not in range(128) #9196

Closed
@javadr

Description

@javadr

Bug report

When I want to use pyplot from matplotlib, it causes error.
There is no problem with import matplotlib but I cannot use pyplot

Code for reproduction

from matplotlib import pyplot

Actual outcome

---------------------------------------------
FileNotFoundErrorTraceback (most recent call last)
/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py in <module>()
   1428         try:
-> 1429             fontManager = pickle_load(_fmcache)
   1430             if (not hasattr(fontManager, '_version') or

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

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

During handling of the above exception, another exception occurred:

UnicodeDecodeErrorTraceback (most recent call last)
<ipython-input-3-a371ea114746> in <module>()
----> 1 from matplotlib import pyplot

/usr/lib64/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

/usr/lib64/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

/usr/lib64/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

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

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

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

/usr/lib64/python3.6/site-packages/matplotlib/font_manager.py in createFontList(fontfiles, fontext)
    581             try:
    582                 try:
--> 583                     font = afm.AFM(fh)
    584                 finally:
    585                     fh.close()

/usr/lib64/python3.6/site-packages/matplotlib/afm.py in __init__(self, fh)
    347         """
    348         (dhead, dcmetrics_ascii, dcmetrics_name, dkernpairs, dcomposite) = \
--> 349             parse_afm(fh)
    350         self._header = dhead
    351         self._kern = dkernpairs

/usr/lib64/python3.6/site-packages/matplotlib/afm.py in parse_afm(fh)
    335     _sanity_check(fh)
    336     dhead = _parse_header(fh)
--> 337     dcmetrics_ascii, dcmetrics_name = _parse_char_metrics(fh)
    338     doptional = _parse_optional(fh)
    339     return dhead, dcmetrics_ascii, dcmetrics_name, doptional[0], doptional[1]

/usr/lib64/python3.6/site-packages/matplotlib/afm.py in _parse_char_metrics(fh)
    196         if not line:
    197             break
--> 198         line = line.rstrip().decode('ascii')  # Convert from byte-literal
    199         if line.startswith('EndCharMetrics'):
    200             return ascii_d, name_d

UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 20: ordinal not in range(128)

Expected outcome

using %matplotlib magic in jupyter notebook also produces the same error.

Matplotlib version

  • Operating System: Fedora 26, 64bit
  • Matplotlib Version: 2.0.0-2
  • Python Version: 2.7 / 3.6
  • Jupyter Version (if applicable): 4.1.0
  • Other Libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: text

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions