导入matplotlib.pyplot作为shell中的plt返回UnicodeDecodeError

时间:2015-02-21 12:37:54

标签: python python-2.7 matplotlib

从open suse下的python shell

Python2。2.7(默认,2013年5月30日,16:55:57)[linux]上的[G​​CC] 输入" help"," copyright"," credit"或"许可证"了解更多信息。

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) 

1 个答案:

答案 0 :(得分:0)

检查您的工作目录路径是否具有非ascii字符,如果这样将工作目录更改为all-ascii字符的路径名。
有关详细信息,请参阅This question and answer