问题描述
当我尝试导入matplotlib时出现错误
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
本身可以正确地反向导入.当我尝试通过以下方式手动安装functools时
backports itself imports properly. When I try to install functools manually via
sudo pip install backports.functools_lru_cache
我得到的信息
Requirement already satisfied: backports.functools_lru_cache in /usr/local/lib/python2.7/dist-packages
尽管如此,当我尝试
import backports.functools_lru_cache
我得到的信息
ImportError: No module named functools_lru_cache
系统信息Ubuntu 16Python 2.7.12点9.0.1
System infoUbuntu 16Python 2.7.12Pip 9.0.1
推荐答案
如果仍然存在该问题并重新安装backports.functools_lru_cache,则在我的情况下无法正常工作,则可能是安装了较旧版本的matplotlib会工作.例如:
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
版本2.2.0出现问题,我切换到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.
这篇关于python 2.7 functools_lru_cache虽然已安装但未导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!