Search code examples
pythonpython-3.xubuntupython-imaging-library

No module named 'PIL'


I'm running into an error where when I try

from PIL import Image, ImageFilter

in a Python file I get an error stating ModuleNotFoundError: No module named 'PIL'.

So far I've tried uninstalling/reinstalling both PIL and Pillow, along with just doing import Image, but the error keeps on occurring and I have no idea why. All the solutions I've found so far have had no effect on my issue.

I'm running Python 3.5 on Ubuntu 16.04


Solution

  • Alright, I found a fix

    To fix the issue, I uninstalled PIL and Pillow through sudo pip3 uninstall pillow and sudo apt-get purge python3-pil. I then restarted and then used sudo -H pip3 install pillow to reinstall Pillow

    The only step I was missing before was rebooting, and not reinstalling PIL afterwards.

    It seems to have worked without any issues so far.