作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
当我尝试导入 matplotlib 时出现错误
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 本身可以正确导入。当我尝试通过
手动安装 functoolssudo 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
最佳答案
如果有人仍然有这个问题并且重新安装 backports.functools_lru_cache 在他的情况下不起作用,就像在我的情况下一样,那么安装旧版本的 matplotlib 可能会起作用。例如:
pip install matplotlib==2.0.2
版本 2.2.0 出现问题,我切换到 2.0.2 并且它现在可以工作。我没有检查其他版本。
关于python 2.7 functools_lru_cache 虽然安装但不导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47179433/
当我尝试导入 matplotlib 时出现错误 Traceback (most recent call last): File "", line 1, in File "/usr/local
我是一名优秀的程序员,十分优秀!