Python: _imagingft C module not installed

I tried many solutions posted on the network, they do not work.

>>> import _imaging >>> _imaging.__file__ 'C:\\python26\\lib\\site-packages\\PIL\\_imaging.pyd' >>> 

Thus, the system can find _imaging, but still cannot use the truetype font

 from PIL import Image, ImageDraw, ImageFilter, ImageFont im = Image.new('RGB', (300,300), 'white') draw = ImageDraw.Draw(im) font = ImageFont.truetype('arial.ttf', 14) draw.text((100,100), 'test text', font = font) 

Causes this error:

 ImportError: The _imagingft C module is not installed File "D:\Python26\Lib\site-packages\PIL\ImageFont.py", line 34, in __getattr__ raise ImportError("The _imagingft C module is not installed") 
+68
python image python-imaging-library
Oct 25 '10 at 3:21
source share
14 answers

The installed PIL was compiled without libfreetype.

Here you can get the pre-compiled PIL installer (compiled using libfreetype) (and many other pre-compiled Python C modules):

http://www.lfd.uci.edu/~gohlke/pythonlibs/

+54
Oct 25 '10 at 3:24
source share

On Ubuntu, you need to install libfreetype-dev before compiling PIL.

i.e.

 $ sudo apt-get install libfreetype6-dev $ sudo -s \# pip uninstall pil \# pip install pil 

PS! Running pip install as sudo usually installs packages in / usr / local / lib on most versions of Ubuntu. You might consider installing Pil in a virtual environment (virtualenv or venv) on a user-owned path.

You can also consider installing a pillow instead of a pilot, which I believe is compatible with the API: https://python-pillow.org .

+69
Apr 24 '11 at 11:20
source share

The following worked for me on Ubuntu 14.04.1 64 bit:

 sudo apt-get install libfreetype6-dev 

Then in virtualenv:

 pip uninstall pillow pip install --no-cache-dir pillow 
+39
Sep 13 '15 at 8:57
source share

for CentOS 6 (and possibly other rpm-based ones):

 yum install freetype-devel libjpeg-devel libpng-devel pip uninstall pil Pillow pip install pil Pillow 
+16
May 12 '13 at 18:04
source share

In OS X, I did this to solve the problem:

 pip uninstall PIL ln -s /usr/X11/include/freetype2 /usr/local/include/ ln -s /usr/X11/include/ft2build.h /usr/local/include/ ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/ ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/libfreetype.dylib pip install PIL 
+14
Aug 01 2018-12-12T00:
source share

Basically, you need to install freetype before installing PIL.

If you are using Homebrew for OS X, this is just a question:

 brew remove pil brew install freetype brew install pil 
+12
Aug 21 2018-12-12T00:
source share

Powered by Ubuntu 12.10:

 sudo pip uninstall PIL sudo apt-get install libfreetype6-dev sudo apt-get install python-imaging 
+12
Jan 26 '13 at 16:22
source share

For OS X (I am running 10.6, but should work for others), I was able to get around this error using the tip of this post . Basically you need to install a couple of dependencies and then reinstall PIL.

+2
Jul 10 2018-12-17T00:
source share

Following is working on ubuntu 12.04:

 pip uninstall PIL apt-get install libjpeg-dev apt-get install libfreetype6-dev apt-get install zlib1g-dev apt-get install libpng12-dev pip install PIL --upgrade 

when you see "jpeg support", which means it works.

But if it still doesn't work when you edit your jpeg image, check the python path!
My python path skipped '/usr/local/lib/python2.7/dist-packages/PIL-1.1.7-py2.7-linux-x86_64.egg/' , so I am editing ~/.bashrc add the following code to this file:

 export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/dist-packages/PIL-1.1.7-py2.7-linux-x86_64.egg/ 

then finally it works !!

+2
Jun 04 '13 at 2:29 on
source share

For me, none of the solutions posted here so far has worked. I found another solution here: http://codeinthehole.com/writing/how-to-install-pil-on-64-bit-ubuntu-1204/

Install the dev packages first:

 $ sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev 

Then create symbolic links:

 $ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/ $ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/ $ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/ 

Subsequently, PIL should only compile a fine:

 $ pip install PIL --upgrade 
+2
Mar 18 '14 at 13:24
source share

I used homebrew to install freetype, and I have the following in / usr / local / lib:

libfreetype.6.dylib libfreetype.a libfreetype.dylib

But the usual one:

pip install pil

Not working for me, so I used:

pip install http://effbot.org/downloads/Imaging-1.1.6.tar.gz

+1
Jan 07 '14 at 16:52
source share

The following steps in the terminal work on my Mac:

 $ brew install freetype $ sudo pip uninstall pil $ sudo pip install pillow 

hopes this works for you. Good luck

+1
Nov 18 '16 at 15:29
source share

Ubuntu 11.10 installs the zlib and freetype2 libraries according to a multi-level specification (e.g. /usr/lib/i386-linux-gnu ). You can use the PIL configuration environment variables so that they can find them. However, it only works with PIL versions behind the pil-117 tag.

 export PIL_SETUP_ZLIB_ROOT=/usr/lib/i386-linux-gnu export PIL_SETUP_FREETYPE_ROOT=/usr/lib/i386-linux-gnu pip install -U PIL 

Since your multicast path may be different (x86-64), it is recommended that you install -dev packages and use pkg-config to get the correct path.

 pkg-config --variable=libdir zlib pkg-config --variable=libdir freetype2 

Another method given by Barry on Pillow setup.py is to use dpkg-architecture -qDEB_HOST_MULTIARCH to get the suffix of the corresponding library directory.

See https://bitbucket.org/effbot/pil-2009-raclette/issue/18

0
May 8 '12 at 19:41
source share

【】 Resolved
In my ubuntu12.04, after I installed python visualization using apt-get, it works.

-one
Mar 18 '14 at 2:50
source share



All Articles