Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install PIL with pip on Mac OS?

I am trying to install PIL (the Python Imaging Library) using the command:

sudo pip install pil 

but I get the following message:

Downloading/unpacking PIL   You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.   Downloading PIL-1.1.7.tar.gz (506kB): 506kB downloaded   Running setup.py egg_info for package PIL     WARNING: '' not a valid package name; please use only.-separated package names in setup.py      Installing collected packages: PIL   Running setup.py install for PIL     WARNING: '' not a valid package name; please use only.-separated package names in setup.py     --- using frameworks at /System/Library/Frameworks     building '_imaging' extension     clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o     unable to execute clang: No such file or directory     error: command 'clang' failed with exit status 1     Complete output from command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-AYrxVD-record/install-record.txt --single-version-externally-managed:     WARNING: '' not a valid package name; please use only.-separated package names in setup.py  running install  running build  . . . .  copying PIL/XVThumbImagePlugin.py -> build/lib.macosx-10.8-intel-2.7  running build_ext  --- using frameworks at /System/Library/Frameworks  building '_imaging' extension  creating build/temp.macosx-10.8-intel-2.7  creating build/temp.macosx-10.8-intel-2.7/libImaging  clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o  unable to execute clang: No such file or directory  error: command 'clang' failed with exit status 1  ---------------------------------------- Cleaning up… 

Could you please help me to install PIL?

like image 249
user3006710 Avatar asked Nov 18 '13 23:11

user3006710


People also ask

Is PIL a package in Python?

Python Imaging Library (expansion of PIL) is the de facto image processing package for Python language. It incorporates lightweight image processing tools that aids in editing, creating and saving images.

How do I run Python pip on Mac?

Open the Terminal app via the Launchpad. In the Terminal, type curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py and press Enter. Allow curl time to download the script onto your Mac. Once it's done, type python3 get-pip.py and press Enter.


2 Answers

  1. Install Xcode and Xcode Command Line Tools as mentioned.
  2. Use Pillow instead, as PIL is basically dead. Pillow is a maintained fork of PIL.

https://pypi.org/project/Pillow/

pip install Pillow 

If you have both Pythons installed and want to install this for Python3:

python3 -m pip install Pillow 
like image 66
FogleBird Avatar answered Sep 19 '22 20:09

FogleBird


This works for me:

apt-get install python-dev apt-get install libjpeg-dev apt-get install libjpeg8-dev apt-get install libpng3 apt-get install libfreetype6-dev ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib  pip install PIL  --allow-unverified PIL --allow-all-external 
like image 26
madjardi Avatar answered Sep 22 '22 20:09

madjardi