python – 2023; anaconda 2022.10; import matplotlib causes: ModuleNotFoundError: No module named ‘PIL’

I was in quite disbelief I would run into this issue with such a well known package. The anaconda is a fresh install. I even conda update conda before trying to run any python file with it.

relavent info:

Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\eliu\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 109, in <module>
    from . import _api, _version, cbook, docstring, rcsetup
  File "C:\Users\eliu\Anaconda3\lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
    from matplotlib.colors import Colormap, is_color_like
  File "C:\Users\eliu\Anaconda3\lib\site-packages\matplotlib\colors.py", line 51, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

also:

(base) PS C:\Users\eliu> conda list matplotlib
# packages in environment at C:\Users\eliu\Anaconda3:
#
# Name                    Version                   Build  Channel
matplotlib                3.6.2            py39haa95532_0
matplotlib-base           3.6.2            py39h1094b8e_0
matplotlib-inline         0.1.6            py39haa95532_0
(base) PS C:\Users\eliu> conda list pillow
# packages in environment at C:\Users\eliu\Anaconda3:
#
# Name                    Version                   Build  Channel
pillow                    9.2.0                    pypi_0    pypi

Read more here: Source link