No module named _imagingft

I have this problem:

No module named _imagingft 

I installed PIL, but it still does not work. I am using OSX.

I am trying to install this module for Django Simple Captcha .

+4
source share
8 answers

Christor's suggestion works very well for me.

Details follow: 1. Remove the existing Python image library.

  • Download and extract the original version (from here http://effbot.org/downloads/Imaging-1.1.6.tar.gz )

  • Install the freetype2 library (you need a reason freetype _imagingft handles TrueType fonts for captcha)

  • Change setup.py (in the source folder extracted from PIL) to match freetype2 (for example, on my VPS with Centos I changed the line "FREETYPE_ROOT = None" to 'FREETYPE_ROOT = "/ usr / local / include"')

  • Create a PIL (python setup.py build) and make sure Freetype2 support is fine

  • Install PIL (python setup.py build)

  • After installation, you can check for the presence of the library by opening the python console and entering the import commands for the _imagingft library. '

If you are using ubuntu, you can use the following guide: http://helloworld.infobart.com/compiling-pil-on-ubuntu-natty

+4
source

Placing a pillow over an existing PIL solved the problem for me:

 $ sudo easy_install PIL $ sudo easy_install Pillow 
+13
source

Thanks to the combination of resources (credit at the end), I put together the following script, which works for me, but YMMV. (Please check it before starting. It may have errors that will eat the liver, shave his cat and drive a car using leaded fuel):

 #!/bin/bash pip-2.6 uninstall PIL # Just in case there a virtualenv someplace: pip uninstall PIL # And forcibly clean up PIL as well rm -rf /Library/Python/2.6/site-packages/PIL* if [ ! -d "/usr/X11/include/freetype2" ];then echo "You need to have XCode installed with the freetype libraries" exit 1 fi # Ok we're good to install ... # Freetype is installed by XCode, so let link to that for PIL's # setup.py to know where to find things 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-2.6 install PIL # OR # pip-2.6 install http://effbot.org/downloads/Imaging-1.1.7.tar.gz 

Credits:

+2
source

It looks like your PIL installation did not support Freetype. You may be missing some Freetype libraries, and so your PIL installation missed the support for it.

Freetype is a font processing technology.

+1
source

I myself struggled with this. The solution is to install Pillow instead of PIL.

Excerpts from https://pypi.python.org/pypi/Pillow/2.0.0 :

The pillow is the "friendly" PIL fork by Alex Clark and Contributors. PIL is a Python image library by Fredrick Lund and contributors.

PIL is not compatible with setuptools .... In addition, PIL's current two-year (or larger) release schedule is too rare to accommodate the large number and frequency of reported problems.

The binary distribution for Windows also has _imagingft. You no longer need to create your own sources.

Download installer packages from: https://pypi.python.org/pypi/Pillow/2.0.0#downloads

Or just install with pip install pillow

+1
source

I had a similar problem and the following solution worked for me, so I decided that I would publish it. Hope this helps someone else when they try out numerous solutions.

Firstly, I think some of the solutions here will work as well, and I used some of the above solutions as a spring board for my own.

[My setting]
I run in my virtual development environment.

Mac OS X 10.7
Pip
Django 1.3.1
Xcode 4.2.1

I found that freetype2 is already included in your Mac OS X installation in / usr / X11 / include

I'm not sure if it is installed with Xcode or just comes by default, but from what I read and understood there are some problems with patents that expired in 2010, so Apple does not include a โ€œfont libraryโ€ by default.

I installed libjpeg earlier to install PIL using HomeBrew.

$ brew install libjpeg

First I installed PIL using pip, but later uninstalled it and decided to install Pillow instead

Believe me or not, it just worked for me.

$ pip install Pillow

Pillow seems to do the hairy job for you, linking and including the source from / usr / X 11 / lib, as shown in the output of the installation procedure below:

Starting setup.py installation for cushion --- using frameworks in / System / Library / Frameworks building up '_imaging' llvm-gcc-4.2 -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 -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_TR -arch i386 -arch x86_64 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -I / System / Library / Frameworks / Tcl. framework / Headers -I / System / Library / Frameworks / Tk.framework / Headers -I / usr / x11 / include / freetype2 -IlibImaging -I / opt / local / include -I / usr / x11 / include -I / Users / /. virtualenvs / canoe_django_env / include -I / usr / local / include -I / usr / include -I / System / Library / Frameworks / Python.framework / Versions / 2.7 / include / python2.7 -c _imaging.c -o build / temp.macosx-10.7-intel-2.7 / _imaging.o

I hope this helps as it worked for me. Sincerely.

0
source

Solution without changing the source code of the PIL:

  • install freetype2-dev package
  • export FREETYPE_ROOT=$(pkg-config --variable=libdir freetype2) # you can change to {path-to-freetype-library} if pkg-config is not available
  • install the latest version of PIL ( pip install https://bitbucket.org/effbot/pil-2009-raclette/get/6a64b3083e35.tar.bz2 )

Related PIL issue .

0
source

Another possible solution if you are using Homebrew:

 brew install freetype brew install Pillow 
0
source

Source: https://habr.com/ru/post/1339562/


All Articles