无法在 Intellij 中导入 matplotlib / Pycharm

Unable to import matplotlib in Intellij / Pycharm

在 pyplot 的初始导入中,intellij 进行了折腾 - unable to load cexceptions:

#!/usr/bin/env python
import sys
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt   # This is the offender
import numpy as np
from numpy import *
import matplotlib.dates as mdt
import dateutil
from collections import namedtuple
 ..

这是输出:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /shared/ysgood/sbin/report.py /tmp/yslogs/0727-095121
unable to load cexceptions
TypeError
p0
(S''
p1
tp2
Rp3
(dp4
S'child_traceback'
p5
S'Traceback (most recent call last):\n  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1280, in _execute_child\n    sys.stderr.write("%s %s (env=%s)\n" %(executable, \' \'.join(args), \' \'.join(env)))\nTypeError\n'
p6
sb.Traceback (most recent call last):
  File "/shared/ysgood/sbin/report.py", line 5, in <module>
    import matplotlib.pyplot as plt
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 24, in <module>
    import matplotlib.colorbar
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/colorbar.py", line 29, in <module>
    import matplotlib.collections as collections
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/collections.py", line 23, in <module>
    import matplotlib.backend_bases as backend_bases
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backend_bases.py", line 50, in <module>
    import matplotlib.textpath as textpath
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/textpath.py", line 11, in <module>
    import matplotlib.font_manager as font_manager
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/font_manager.py", line 1356, in <module>
    _rebuild()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/font_manager.py", line 1341, in _rebuild
    fontManager = FontManager()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/font_manager.py", line 989, in __init__
    self.ttffiles = findSystemFonts(paths) + findSystemFonts()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/font_manager.py", line 318, in findSystemFonts
    for f in get_fontconfig_fonts(fontext):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/font_manager.py", line 274, in get_fontconfig_fonts
    pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init_

我在 Yosemite 上使用最新的 IJ 14.1.4。

我无法直接解决。相反,我安装了 brew 版本 python 2.7.8.2 作为模块的 python SDK。

然而,这并不是故事的结局。在出现奇怪的错误后——比如抱怨输出路径相同——我做了 Invalidate Caches。又过了十五分钟就一切都好了