matplotlib问题突然出现

时间:2018-03-26 11:04:20

标签: python matplotlib pip importerror

我遇到了这个问题

Traceback (most recent call last):
  File "Path.py", line 4, in <module>
    import matplotlib.pyplot as plt
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 131, in <module>
    from matplotlib.rcsetup import defaultParams, validate_backend, cycler
  File "C:\Python27\lib\site-packages\matplotlib\rcsetup.py", line 29, in <module>
    from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
  File "C:\Python27\lib\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

到目前为止我已尝试过: -

  • 要卸载functools_lru_cache并重新安装
  • 要卸载matplotlib并重新安装
  • 从site-dist中删除文件夹并重新安装

我已经为VS Code安装了 Python和Pylint 。它不仅与VS Code有关,我也无法直接从CMD运行代码。

1 个答案:

答案 0 :(得分:0)

考虑使用此技术导入'lru_cache'函数:

try:
    from functools import lru_cache
except ImportError:
    from backports.functools_lru_cache import lru_cache

无论如何,这是网站: https://pypi.python.org/pypi/backports.functools_lru_cache

你也可以在行命令

中这样做
pip install backports.functools_lru_cache