1

我安装了 matplotlib 网站上列出的所有依赖项。但是,它仍然不起作用。我在下面列出了 python 堆栈跟踪并安装了 python 包。那么,我该如何解决这个问题呢?

Python堆栈跟踪:

>>> import pylab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/Library/Python/2.7/site-packages/matplotlib/pylab.py", line 229, in <module>
    import matplotlib.finance
  File "/Library/Python/2.7/site-packages/matplotlib/finance.py", line 37, in <module>
    from matplotlib.collections import LineCollection, PolyCollection
  File "/Library/Python/2.7/site-packages/matplotlib/collections.py", line 26, in <module>
    import matplotlib.backend_bases as backend_bases
  File "/Library/Python/2.7/site-packages/matplotlib/backend_bases.py", line 54, in <module>
    import matplotlib.textpath as textpath
  File "/Library/Python/2.7/site-packages/matplotlib/textpath.py", line 18, in <module>
    import matplotlib.font_manager as font_manager
  File "/Library/Python/2.7/site-packages/matplotlib/font_manager.py", line 1354, in <module>
    _rebuild()
  File "/Library/Python/2.7/site-packages/matplotlib/font_manager.py", line 1339, in _rebuild
    fontManager = FontManager()
  File "/Library/Python/2.7/site-packages/matplotlib/font_manager.py", line 987, in __init__
    self.ttffiles = findSystemFonts(paths) + findSystemFonts()
  File "/Library/Python/2.7/site-packages/matplotlib/font_manager.py", line 316, in findSystemFonts
    for f in get_fontconfig_fonts(fontext):
  File "/Library/Python/2.7/site-packages/matplotlib/font_manager.py", line 280, in get_fontconfig_fonts
    for line in output.split('\n'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 16560: ordinal not in range(128)

安装的python包:

>$ pip freeze
PyRSS2Gen==1.0.0
Twisted==12.0.0
altgraph==0.9
bdist-mpkg==0.4.4
bonjour-py==0.3
macholib==1.4.2
matplotlib==1.4.x
modulegraph==0.9.1
nose==1.3.0
numpy==1.7.1
py2app==0.6.3
pyOpenSSL==0.13
pyobjc-core==2.3.2a0
pyobjc-framework-AddressBook==2.3.2a0
pyobjc-framework-AppleScriptKit==2.3.2a0
pyobjc-framework-AppleScriptObjC==2.3.2a0
pyobjc-framework-Automator==2.3.2a0
pyobjc-framework-CFNetwork==2.3.2a0
pyobjc-framework-CalendarStore==2.3.2a0
pyobjc-framework-Cocoa==2.3.2a0
pyobjc-framework-Collaboration==2.3.2a0
pyobjc-framework-CoreData==2.3.2a0
pyobjc-framework-CoreLocation==2.3.2a0
pyobjc-framework-CoreText==2.3.2a0
pyobjc-framework-DictionaryServices==2.3.2a0
pyobjc-framework-ExceptionHandling==2.3.2a0
pyobjc-framework-FSEvents==2.3.2a0
pyobjc-framework-InputMethodKit==2.3.2a0
pyobjc-framework-InstallerPlugins==2.3.2a0
pyobjc-framework-InstantMessage==2.3.2a0
pyobjc-framework-InterfaceBuilderKit==2.3.2a0
pyobjc-framework-LatentSemanticMapping==2.3.2a0
pyobjc-framework-LaunchServices==2.3.2a0
pyobjc-framework-Message==2.3.2a0
pyobjc-framework-OpenDirectory==2.3.2a0
pyobjc-framework-PreferencePanes==2.3.2a0
pyobjc-framework-PubSub==2.3.2a0
pyobjc-framework-QTKit==2.3.2a0
pyobjc-framework-Quartz==2.3.2a0
pyobjc-framework-ScreenSaver==2.3.2a0
pyobjc-framework-ScriptingBridge==2.3.2a0
pyobjc-framework-SearchKit==2.3.2a0
pyobjc-framework-ServerNotification==2.3.2a0
pyobjc-framework-ServiceManagement==2.3.2a0
pyobjc-framework-SyncServices==2.3.2a0
pyobjc-framework-SystemConfiguration==2.3.2a0
pyobjc-framework-WebKit==2.3.2a0
pyobjc-framework-XgridFoundation==2.3.2a0
pyparsing==2.0.1
python-dateutil==2.1
scipy==0.12.0
six==1.4.1
stevedore==0.11
tornado==3.1.1
virtualenv==1.10.1
virtualenv-clone==0.2.4
virtualenvwrapper==4.1.1
wsgiref==0.1.2
xattr==0.6.2
zope.interface==3.5.1
4

1 回答 1

5

这是 matplotlib 1.4.x 中的一个错误,fontmanager.py它试图导入名称包含非 ascii 字符的字体。

您的问题与问题类似,但给出的补丁对您没有帮助,因为您安装了 matplotlib 1.4.x 而不是 1.3.0。

正如上面问题中所建议的,您可以查看您的字体列表并尝试删除带有非 ascii 字符的字体。特别寻找Æ.

或者,您可以尝试升级到似乎已修复的 matplotlib 开发版本:

pip install git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev
于 2013-09-09T04:53:43.847 回答