PIL Library doesnt exist in python

Is there any way to fix python thinking PIL doesnt exist? I found another post that solved the issue by forking an older replit but every time I open the replit, it just auto updates to the newest version and stops working.

Current behavior:
It just says it cannot find PIL library

Desired behavior
It… says PIL exists

Repl link:
main.py - name here - Replit

from PIL import Image, ImageDraw, ImageFont, ImageColor

I’m having the same issue with matplotlib.pyplot. Now whenever I open any of my replits it auto updates and stops working…

Can you try running curl https://pythonify.util.repl.co/recreate_python3_venv.sh | bash in the shell of your Repl to create a new python virtual environment?

I had the same issue, manually installing Pillow with pip install pillow should fix your issue.

1 Like

It happens because replits auto import feature tries to find a package named PIL when it is actually named pillow.

To fix this, we will disable this for that repl.

  1. Go to .replit file and change the guessImports = true to guessImports = false
  2. Go to shell and do poetry add pillow

Run your code. It should work.

Note: after doing this, you need to add all new packages manually using poetry in the same manner: poetry add <package name>

1 Like

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