Python matplotlib – ImportError: Kein Modul mit dem Namen functools_lru_cache

Python matplotlib – ImportError: Kein Modul mit dem Namen functools_lru_cache

Ich habe die Installation matplotlibfür Python durchgeführt pip, die ohne Fehler abgeschlossen wurde. Dennoch erhalte ich diesen Fehler, wenn ich versuche, es zu importieren:

import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rishabh/.local/lib/python2.7/site-packages/matplotlib/__init__.py", line 131, in <module>
    from matplotlib.rcsetup import defaultParams, validate_backend, cycler
  File "/home/rishabh/.local/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 29, in <module>
    from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
  File "/home/rishabh/.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

Antwort1

versuche dies, ich hatte heute Morgen dasselbe Problem

sudo apt-get install python-matplotlib

Ich verwende auch Python 3.7, etwas später, nachdem ich einige Module installiert habe. Ich habe es ausgeführt.

pip3 install matplotlib

Ich kann jetzt Matplotlib importieren.

Antwort2

Zuerst deinstallieren

pip uninstall backports.functools_lru_cache

und dann neu installieren

pip install backports.functools_lru_cache

wie beschriebenin dieser Antwort.

verwandte Informationen