Cannot import name '_c_internal_utils' from 'matplotlib'

I recently installed Windows 11. Now, when I try to import matplotlib on my Jupyter Notebook, I get the error message below. Maybe it is not related to this, but when I was on Windows 10 everything was fine


ImportError Traceback (most recent call last)
in
----> 1 import matplotlib.pyplot as plt

~\AppData\Roaming\Python\Python37\site-packages\matplotlib_init_.py in
107 # cbook must import matplotlib only within function
108 # definitions, so it is safe to import from it here.
→ 109 from . import _api, _version, cbook, docstring, rcsetup
110 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
111 from matplotlib.cbook import mplDeprecation # deprecated

~\AppData\Roaming\Python\Python37\site-packages\matplotlib\cbook_init_.py in
29
30 import matplotlib
—> 31 from matplotlib import _api, _c_internal_utils
32 from matplotlib._api.deprecation import (
33 MatplotlibDeprecationWarning, mplDeprecation)

ImportError: cannot import name 'c_internal_utils’ from ‘matplotlib’ (C:\Users\catel\AppData\Roaming\Python\Python37\site-packages\matplotlib_init.py)

_c_internal_utils is a compiled extension module. It is likely that either you need to recompile or are missing the msvc redistribute library.

I suggest re-installing on the new OS.

I had the same error while importing matplotlib in anaconda. The “(most likely due to circular import)” is a good directive. I had PYTHONPATH in my environmental variables. Anaconda does not need PYTHONPATH (https://docs.anaconda.com/anaconda/user-guide/faq).

Once I deleted the PYTHONPATH, it worked. (Also, if there any other Python installations in the path enviornmental variable, remove them so that the only paths are the ones you are currently using, i.e. anaconoda)