0

I'm trying to use the Django-simple-captcha http://django-simple-captcha.readthedocs.org/en/latest/usage.html in my django app. But the captcha image is not showing up in the templates. I get the following error when I viewed the source code in my browser. I've followed the documenation carefully and have syncdb everything.

Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/captcha/views.py" in captcha_image
  46.         font = ImageFont.truetype(settings.CAPTCHA_FONT_PATH, settings.CAPTCHA_FONT_SIZE * scale)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py" in truetype
  228.         return FreeTypeFont(font, size, index, encoding)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py" in __init__
  131.             self.font = core.getfont(font, size, index, encoding)
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py" in __getattr__
  42.         raise ImportError("The _imagingft C module is not installed")

Exception Type: ImportError at /captcha/image/f02c7bf84cd31c4caf8d6b2f8931a01689902c83/
Exception Value: The _imagingft C module is not installed

I know that this question has been asked several times before and I've read several stackoverflow answers but I'm still very confused about the course of action.

I've Pillow installed on my OSX Mavericks.

ferrangb
  • 2,012
  • 2
  • 20
  • 34
James L.
  • 1,143
  • 22
  • 52
  • I hope Pillow was installed with libjpeg support? – Shrey Jun 17 '14 at 06:28
  • I already had Pillow installed when installing Django a while back. I just did brew install libtiff libjpeg webp little-cms2 to install libjeg. But the image is still now showing up properly and getting the same error. – James L. Jun 17 '14 at 07:15
  • if you brewed libjpeg after installing pillow, you should uninstall and install pillow again. And watch out for the --- JPEG support not available when pillow installation is finished. – Shrey Jun 17 '14 at 07:33
  • I did that and no JPEG support issue. But I still have the error, no change! – James L. Jun 17 '14 at 07:37
  • Ignore if you have done so; check if pillow has freetype support as well. check similar posts : http://stackoverflow.com/questions/4984979/no-module-named-imagingft , http://stackoverflow.com/questions/4011705/python-the-imagingft-c-module-is-not-installed – Shrey Jun 17 '14 at 08:12

2 Answers2

1

I solved the above error by installing freetype and freetype2 devel packages before running pip install Pillow.

Worked on SuSE Linux.

guettli
  • 25,042
  • 81
  • 346
  • 663
0

Works for me in ubuntu 14.04:

pip uninstall pil

or(depends what you are using)

 pip uninstall pillow

then

sudo apt-get update

apt-get install libfreetype6-dev libxft-dev  libjpeg62  libjpeg-devel

in the output, make sure the installation was complete

And finnaly

pip install pil

or

pip install pillow
Renato Prado
  • 3,770
  • 4
  • 21
  • 26