Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: The _imagingft C module is not installed

I've tried lots of solution that posted on the net, they don't work.

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

So the system can find the _imaging but still can't use 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) 

Raises 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") 
like image 623
user483144 Avatar asked Oct 25 '10 03:10

user483144


Video Answer


2 Answers

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

i.e.

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

PS! Running pip install as sudo will usually install packages to /usr/local/lib on most Ubuntu versions. You may consider to install Pil in a virtual environment (virtualenv or venv) in a path owned by the user instead.

You may also consider installing pillow instead of pil, which I believe is API compatible: https://python-pillow.org. Note that Pillow also requires libfreetype-dev and you might need to follow the same uninstall/install steps if libfreetype-dev was not present during the initial installation.

like image 171
Sindre Myren Avatar answered Sep 21 '22 14:09

Sindre Myren


Your installed PIL was compiled without libfreetype.

You can get precompiled installer of PIL (compiled with libfreetype) here (and many other precompiled Python C Modules):

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

like image 24
Imran Avatar answered Sep 21 '22 14:09

Imran