Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

matplotlib - python 2.7 functools_lru_cache does not import although installed

When I try to import matplotlib I get an error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 128, in <module>
  from matplotlib.rcsetup import defaultParams, validate_backend, cycler
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/rcsetup.py", line 29, in <module>
    from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/fontconfig_pattern.py", line 32, in <module>
    from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache

backports itself imports properly. When I try to install functools manually via

sudo pip install backports.functools_lru_cache

I get info that

Requirement already satisfied: backports.functools_lru_cache in /usr/local/lib/python2.7/dist-packages

Nevertheless when i try to

import backports.functools_lru_cache

I get info that

ImportError: No module named functools_lru_cache

System info Ubuntu 16 Python 2.7.12 Pip 9.0.1

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If someone is still having that problem and reinstalling backports.functools_lru_cache do not work in his case, as it was in my case, then probably installing older version of matplotlib would work. For example:

pip install matplotlib==2.0.2

Problem occurred for version 2.2.0, I switched to 2.0.2 and it is working now. I did not check other versions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...