Skip to content Skip to sidebar Skip to footer

Using Pillow For Python 3.7 Mac Os?

I have Pillow installed successfully on my Mac, but when I type in from PIL import Image I get an error: 'Unable to import 'PIL' I'm using VSCode by the way. Anyone know how to f

Solution 1:

If you installed Pillow with:

pip install pillow

then you can find where it is installed with:

pip show pillow

Sample Output

Name: PillowVersion: 7.1.2Summary: Python Imaging Library (Fork)Home-page: https://python-pillow.orgAuthor: Alex Clark (PIL Fork Author)Author-email: aclark@python-pillow.orgLicense: HPNDLocation: /usr/local/lib/python3.7/site-packages     <--- HERE

Of course, if you installed with:

pip3 install pillow

you will need:

pip3 show pillow

Now go to your Python interpreter and check where it is looking for packages and you will surely work out the problem:

python3 -c "import sys; print(sys.path)" | tr , '\n'

Samnple output

[
'/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python36.zip''/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6''/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload''/usr/local/lib/python3.6/site-packages''/usr/local/Cellar/numpy/1.13.3/libexec/nose/lib/python3.6/site-packages']

Of course, if you start Python with python rather than python3, you will need:

python -c "import sys; print(sys.path)" | tr , '\n'

Finally, go to your Terminal and find out what your shell actually runs when you enter python by running:

type python            # or "type python3" if you normally enter "python3"

Now go in your IDE and see which Python that runs:

import sys
print(sys.executable)

Post a Comment for "Using Pillow For Python 3.7 Mac Os?"