0

I just cannot find any solution for this

no matter if I run the code in Jupyter or from the command line

even after installing Pillow

>pip install Pillow
Requirement already satisfied: Pillow in c:\users\phil\appdata\local\programs\python\python39\lib\site-packages (9.0.1)

>pip3 install Pillow
Requirement already satisfied: Pillow in c:\users\phil\appdata\local\programs\python\python39\lib\site-packages (9.0.1)

matplotlib keeps trying to use an obsolete plugin

>python test3.py
Traceback (most recent call last):
  File "\test3.py", line 2, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\phil\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\__init__.py", line 113, in <module>
    from . import _api, _version, cbook, _docstring, rcsetup
  File "C:\Users\phil\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
    from matplotlib.colors import Colormap, is_color_like
  File "C:\Users\phil\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\colors.py", line 51, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

workaround I had to edit matplotlibfiles to replace PIL by pi to make it work

  • is there no other way around this ?
  • is matplotlib deprecated ?

any help appreciated

phil123456
  • 13
  • 3
  • Does this answer your question? [ImportError: No module named ...](https://stackoverflow.com/a/73398463/19290081) – Jamiu S. Nov 01 '22 at 16:45
  • no, that's why I posted this. since I used pip I'd expect matplotlib and Pillow would be compatible – phil123456 Nov 01 '22 at 17:30
  • Try this in command line, `python` and the `import PIL` then post the output in your question. – Avi Nov 02 '22 at 10:17

1 Answers1

0

The package is installed in a different venv while you are in another. You can append the package directory into your working environment before you import.

import sys
sys.path.append("c:/users/phil/appdata/local/programs/python/python39/lib/site-packages")
from PIL import Image
Jamiu S.
  • 5,257
  • 5
  • 12
  • 34
  • well no, this is precisely what is imported and I had to replace all 'PIL' by 'pil' in >40 files – phil123456 Nov 01 '22 at 17:28
  • Your python libs are getting installed at different place, you will definitely that where exactly it is getting installed. – Avi Nov 02 '22 at 10:19
  • I used pip and pip3. replying package is already installed. I was expecting the packages to be installed and used there. I'll keep digging but it makes no sense so far – phil123456 Dec 07 '22 at 13:25