Search code examples
pythonpypy

Pillow with pypy, The _imagingft C module is not installed


Pillow with pypy on CentOS release 6.8 not work, i use pip uninstall / install pillow is ok, but still "ImportError: The _imagingft C module is not installed", this is the out put :

[root@localhost bin]# ./pip install pillow
Collecting pillow
Requirement already satisfied: olefile in /usr/local/pypy-5.6-linux_x86_64-portable/site-packages (from pillow)
Installing collected packages: pillow
Successfully installed pillow-4.0.0

[root@localhost bin]# ./pypy
Python 2.7.12 (aff251e543859ce4508159dd9f1a82a2f553de00, Nov 12 2016, 08:50:18)
[PyPy 5.6.0 with GCC 6.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> from PIL import Image, ImageDraw, ImageFilter, ImageFont
draw.text((100,100), 'test text', font = font)>>>> im = Image.new('RGB', (300,300), 'white')
>>>> draw = ImageDraw.Draw(im)
>>>> font = ImageFont.truetype('Arial.ttf', 14)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/pypy-5.6-linux_x86_64-portable/site-packages/PIL/ImageFont.py", line 238, in truetype
    return FreeTypeFont(font, size, index, encoding)
  File "/usr/local/pypy-5.6-linux_x86_64-portable/site-packages/PIL/ImageFont.py", line 127, in __init__
    self.font = core.getfont(font, size, index, encoding)
  File "/usr/local/pypy-5.6-linux_x86_64-portable/site-packages/PIL/ImageFont.py", line 37, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

i use : pip install pil

[root@localhost bin]# ./pip install PIL
Collecting PIL
  Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL

its not work

i use : pip install http://effbot.org/downloads/Imaging-1.1.6.tar.gz install is ok, but still "ImportError: No module named _imagingft"

i also download the source tar of pillow, but too many libs not found ! installed libs :

SYSPKGS="$SYSPKGS kernel python python-devel telnet subversion libffi libffi-devel"
SYSPKGS="$SYSPKGS tcl tk ncurses-devel expat-devel bzip2-devel sqlite-devel"
SYSPKGS="$SYSPKGS openssl-devel openssl pcre pcre-devel libxml2-devel libxslt-devel"
SYSPKGS="$SYSPKGS libtiff-devel libjpeg-devel libjpeg-turbo-static freetype-devel"
SYSPKGS="$SYSPKGS zlib zlib-devel zlib-static wget curl net-tools"

yum -y install $SYSPKGS 

most google's result is for ubuntu, win, macOS, any solution for centos6.8 ?

HELP ! :(


Solution

  • Pillow's 4.0.0 doesn't work with PyPy: I had to fix distutils inside PyPy before I could get it installed at all. With this fix, your example works.

    You can install manually the fix by adding a few lines to the file lib-python/2.7/distutils/unixccompiler.py inside your PyPy distirbution: see https://bitbucket.org/pypy/pypy/commits/66ef3eb6a91e . It will also be included in the next PyPy release.