gpt4 book ai didi

python 2.7 functools_lru_cache 虽然安装但不导入

转载 作者:IT老高 更新时间:2023-10-28 22:13:02 26 4
gpt4 key购买 nike

当我尝试导入 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 本身可以正确导入。当我尝试通过

手动安装 functools
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

最佳答案

如果有人仍然有这个问题并且重新安装 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com