导入matplotlib.pyplot时的Matplotlib TypeError

Adr*_* Mc 5 matplotlib stdstring typeerror python-2.7

我刚用conda来更新我的Anaconda安装,Matplotlib从v1.4.0升级到v1.4.2.但是现在我使用Matplotlib.pyplot的所有Python作业都抛出异常.

即使是简单的命令:

import matplotlib.pyplot as plt
Run Code Online (Sandbox Code Playgroud)

抛出TypeError异常,说:

无法从Unicode对象返回std :: string

回溯告诉我在font_manager.py文件中发生了异常,这里:

try:
    font = ft2font.FT2Font(fpath)
except RuntimeError:
    verbose.report("Could not open font file %s" % fpath)
    continue
except UnicodeError:
    verbose.report("Cannot handle unicode filenames")
    continue
Run Code Online (Sandbox Code Playgroud)

特别是在线font = ft2font.FT2Font(fpath).

我尝试回到Matplotlib的v1.4.0,但它没有解决问题.

然后我编辑了font_manager.py来添加一般的异常情况:

except:
    verbose.report("Some stupid error occurred")
    continue
Run Code Online (Sandbox Code Playgroud)

希望它会暂时解决它所遇到的问题,但是这个错误或者与之类似的错误会在以后发生.所以我删除了异常,但错误现在仍然发生在代码的后一点(所以如果我运行import matplotlib.pyplot as plt它,但执行其他命令可能会失败).

我使用Matplotlib全天生成/更新数百个图表,现​​在一切都坏了.

请帮忙!谢谢!

Adr*_* Mc 1

似乎卸载 Anaconda 并重新安装新版本可以解决 @pbreach 提到的问题,因此关闭此问题。