我已經安裝了matplotlib
Python,使用pip
它已完成,沒有錯誤。然而,當我嘗試導入它時,出現此錯誤:
import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rishabh/.local/lib/python2.7/site-packages/matplotlib/__init__.py", line 131, in <module>
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
File "/home/rishabh/.local/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 29, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "/home/rishabh/.local/lib/python2.7/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
答案1
試試這個我今天早上遇到了同樣的問題
sudo apt-get install python-matplotlib
在安裝了一些模組之後,我也在使用 python3.7。我跑了。
pip3 install matplotlib
我現在可以導入 matplotlib。
答案2
先卸載
pip uninstall backports.functools_lru_cache
然後重新安裝
pip install backports.functools_lru_cache
就像描述的那樣在這個答案中。