【问题标题】:import matplotlib.pyplot as plt in shell returns UnicodeDecodeError在 shell 中导入 matplotlib.pyplot 作为 plt 返回 UnicodeDecodeError
【发布时间】:2015-04-23 03:06:41
【问题描述】:

从open suse下的python shell

Linux2 上的 Python 2.7.5(默认,2013 年 5 月 30 日,16:55:57)[GCC] 输入“help”、“copyright”、“credits”或“license”了解更多信息。

import matplotlib.pyplot as plt

返回以下内容。任何帮助表示赞赏。

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 24, in <module>
    import matplotlib.colorbar
  File "/usr/lib64/python2.7/site-packages/matplotlib/colorbar.py", line 29, in <module>
    import matplotlib.collections as collections
  File "/usr/lib64/python2.7/site-packages/matplotlib/collections.py", line 23, in <module>
    import matplotlib.backend_bases as backend_bases
  File "/usr/lib64/python2.7/site-packages/matplotlib/backend_bases.py", line 50, in <module>
    import matplotlib.textpath as textpath
  File "/usr/lib64/python2.7/site-packages/matplotlib/textpath.py", line 11, in <module>
    import matplotlib.font_manager as font_manager
  File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1356, in <module>
    _rebuild()
  File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1341, in _rebuild
    fontManager = FontManager()
  File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1004, in __init__
    self.ttflist = createFontList(self.ttffiles)
  File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 584, in createFontList
    prop = ttfFontProperty(font)
  File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 398, in ttfFontProperty
    sfnt4 = sfnt4.decode('ascii').lower()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xaa in position 7: ordinal not in range(128) 

【问题讨论】:

    标签: python python-2.7 matplotlib


    【解决方案1】:

    检查您的工作目录路径是否包含非 ascii 字符,如果是,请将您的工作目录更改为全 ascii 字符的路径名。
    更多信息请参考This question and answer。

    【讨论】:

      猜你喜欢
      • 2019-02-26
      • 1970-01-01
      • 1970-01-01
      • 2015-06-08
      • 2014-08-09
      • 2017-11-05
      • 2013-12-27
      • 1970-01-01
      • 2014-12-05
      相关资源
      最近更新 更多