Python matplotlib - ImportError: Nenhum módulo chamado functools_lru_cache

Python matplotlib - ImportError: Nenhum módulo chamado functools_lru_cache

Eu instalei matplotlibpara Python usando pipo qual foi concluído sem erros. No entanto, recebo este erro quando tento importá-lo:

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

Responder1

tente isso, tive o mesmo problema esta manhã

sudo apt-get install python-matplotlib

Também estou usando o python3.7 um pouco mais tarde, depois de instalar alguns módulos. Eu corri.

pip3 install matplotlib

Agora posso importar matplotlib.

Responder2

Desinstale primeiro

pip uninstall backports.functools_lru_cache

e depois reinstale-o

pip install backports.functools_lru_cache

como descritonesta resposta.

informação relacionada