我最近将我的Ubuntu更新为18.04,现在使用Python(2.7)时我无法再导入matplotlib。导入时出错:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/.local/lib/python2.7/site-packages/matplotlib/__init__.py", line 131, in <module>
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
File "~/.local/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 29, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "~/.local/lib/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 28, in <module>
from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache
我通过
安装了matplotlibpip install --user matplotlib
与matplotlib一样,functools_lru_cache-module安装在
中~/.local/lib/python2.7/site-packages
我在这里缺少什么?
我尝试卸载并重新安装“functools_lru_cache”模块,如下所示: python 2.7 functools_lru_cache does not import although installed 但这没有帮助。还是一样的错误。
答案 0 :(得分:0)
通过pip卸载matplotlib并安装旧版本(2.0.2)为我解决了这个问题。请参阅:https://stackoverflow.com/a/49335954/1627966