python matplotlib cannot import name ‘artist‘ from ‘matplotlib‘

问题:

import matplotlib.pyplot as plt 报错

cannot import name 'artist' from 'matplotlib'

搜索后发现可能是误删文件导致的,需要卸载matplotlib后重新安装,但是无法卸载,会报错

Cannot uninstall matplotlib 3.4.3, RECORD file not found.   You might be able to recover from this via: 'pip install --force-reinstall --no-deps matplotlib==3.4.3'.

按照要求使用

pip install --force-reinstall --no-deps matplotlib==3.4.3

还是没用。不卸载,直接用

pip install matplotlib

安装也不行,限定matplotlib的版本也没用

解决:

无意中想起来之前遇到过类似的问题,就尝试了一下当时的解决办法,没想到竟然有用

  • conda install --yes freetype=2.10.4

如果其他方法都没用的话,可以试试这个;)

参考:Jupyter中使用matplotlib画图出现kernel died问题_BuCCiaRaTi B的博客-CSDN博

你可能感兴趣的:(python)