PIL and Pillow not found


Here is an easy code that works last year with my students. The goal is no show them some manipulations with images.

from os import system

system("pip install Pillow")
from PIL import Image

imageSource = Image.open("pomme.jpg")
r, v, b = imageSource.getpixel((100, 250))
print("Rouge :", r, "Vert :", v, "Bleu :", b)

It doesn’t work anymore! It seems there is a problem with PIL.

Here is the error message:

  File "/home/runner/Manu-1/main.py", line 3, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

Could some of you help me?

Thanks a lot!


Welcome to the forums, @2deSNTpasteur!
Try running poetry add PIL in the :shell: shell. In Replit, pip doesn’t work, and also it is better to use the shell then to use os.system, so if you do this, please remove these lines of code:

1 Like

Try pip install PIL or poetry add PIL?

Usually after this installing once you don’t need to run it again, so you can just remove the from os import system and the system(shell) run commend

It does, Replit is just built to work with poetry. poetry actually uses pip.

1 Like

Well actually, you should use upm, which is Replit’s Universal Package Manager. (which uses poetry which uses pip)

1 Like

Thank you All for tour help.
I tried your solutions but gère us what it gives

I don’t really understand your answer QwertyQwerty88. Are you telling me I have to install the upm package ? I don’t find it.

Thanks again !

1 Like

No, it should come by default.

The previous advice seems to be wrong. PIL is what you import, but not the name of the package you install.

Try upm add Pillow in the Shell.


Yeah just found out PIL isn’t a package name but more like module

You should run poetry add pillow

1 Like

Thanks! but unfortunaltely, still not working.

bug replit

I tried several instructions. Tried to modify my code, but always the same error: (No module named ‘PIL’…

Hi @2deSNTpasteur !
Can you go to poetry.lock and press CTRL+F to search and search in ‘pillow’?
If it’s not there, try doing poetry remove pillow then poetry add pillow or poetry add pillow.PIL if the previous command doesn’t work.


Thanks a lot NateDhaliwal!

It worked! I’ll try my other little script to see if they all work.

Thank to all of you who took some of your time to help me.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.