Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

from PIL import Image - ImportError: No module named PIL

I know there are a number of questions already on stackoverflow related to this issue and I have read them all, but still I am having no success with this issue. I am hoping somebody can help me out with this.

I have installed and reinstalled Pillow 10 times now. I have updated my .bash_profile. Still, I get the same error message.

This is my .bash_profile:

export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH="$PATH:/usr/local/bin/"
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

This is my code:

import sys
import string
import re
from PIL import Image

It chokes on the 4th line every time with the message: ImportError: No module named PIL. I have also tried replacing the fourth line with

import Image

also with no success. I know there are many questions similar to this one on here but believe me I have been reading the answers on those with no success so I'm hoping somebody here can help me with my particular situation. Thanks!

like image 306
swanb034 Avatar asked Oct 28 '14 02:10

swanb034


2 Answers

I was experiencing a similar issue. Fixed it by pip installing WITHOUT sudo.

pip install pillow

instead of

sudo pip install pillow
like image 82
blearn Avatar answered Oct 19 '22 05:10

blearn


I encountered this while installing tensorflow code on NVIDIA Jetson Nano. This works for me:

    pip3 install Image
like image 41
Subbiah Thannirmalai Avatar answered Oct 19 '22 05:10

Subbiah Thannirmalai