Al importar matplotlib import matplotlib.pyplot as plt , recibo el siguiente error:
Traceback (most recent call last): File "mode.py", line 1, in <module> import matplotlib.pyplot as plt File "C:\Users\yuhan\AppData\Roaming\Python\Python36\site-packages\matplotlib\pyplot.py", line 32, in <module> import matplotlib.colorbar File "C:\Users\yuhan\AppData\Roaming\Python\Python36\site-packages\matplotlib\colorbar.py", line 32, in <module> import matplotlib.artist as martist File "C:\Users\yuhan\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py", line 16, in <module> from .path import Path File "C:\Users\yuhan\AppData\Roaming\Python\Python36\site-packages\matplotlib\path.py", line 25, in <module> from . import _path, rcParams ImportError: cannot import name '_path'Intenté reinstalar toda la biblioteca matplotlib, intenté reinstalar Python 3.6, etc. Realmente no sé qué está mal y como no tengo una copia de seguridad.
py -m pip uninstall matplotlibentonces:
py -m pip install matplotlibfuncionó para mí para ese error también.
Luego tuve el problema de que no se encontraba kiwisolver, e hice lo mismo desinstalar, instalar para kiwisolver y ahora: import matplotlib.pyplot as plt .
Este problema puede surgir cuando copia bibliotecas de un lugar a otro (al menos eso es lo que me pasó a mí: P)
Asegúrese de que en .../Python37/Lib/site-packages haya un archivo llamado: matplotlib-3.0.2-py3.7-nspkg.pth con la versión correcta de Python y matplotlib
(en este ejemplo estoy usando python 3.7.1 y matplotlib 3.0.2)
Si ese no es el caso, reinstale matplotlib como sugirieron otros usuarios. Asegúrese también de apuntar al directorio correcto (a veces he visto que el problema podría ser la versión incorrecta de pip)