Import fails on matplotlib 3.8.0 but works in 3.7.0

Hello ,
I installled matplotlib using ‘pip install matplotlib’ which defaults to installing matlplot lib version 3.8.0
however If I try importing it to my .py file it fails with the following error:
traceback (most recent call last):
** File “/home//Documents/vscode/python/scripts/script.py”, line 1, in **
** import matplotlib.pyplot as plt**
** File “/home//.local/lib/python3.10/site-packages/matplotlib/pyplot.py”, line 66, in **
** from matplotlib.figure import Figure, FigureBase, figaspect**
** File “/home//.local/lib/python3.10/site-packages/matplotlib/figure.py”, line 43, in **
** from matplotlib import _blocking_input, backend_bases, _docstring, projections**
** File “/home//.local/lib/python3.10/site-packages/matplotlib/projections/init.py”, line 58, in **
** from mpl_toolkits.mplot3d import Axes3D**
** File “/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/init.py”, line 1, in **
** from .axes3d import Axes3D**
** File “/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/axes3d.py”, line 23, in **
** from matplotlib import _api, cbook, docstring, _preprocess_data**
ImportError: cannot import name ‘docstring’ from ‘matplotlib’ (/home//.local/lib/python3.10/site-packages/matplotlib/init.py)

I’m using python version 3.10.12
however matlib 3.7.0 works fine

I’m not sure if this is a bug or relates to configuration
I will really appreciate any help
Thanks ,

See the discussions in this GitHub issue: [Bug]: ImportError when using Matplotlib v3.8.0 in Python package tests · Issue #26827 · matplotlib/matplotlib · GitHub

1 Like