python PIL ImportError: The _imagingft C module is not installed
2012-07-06 16:40
781 查看
# import _imaging : No module named _imaging
# 需要先安装jpeg库
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7
CC="gcc -arch x86_64"
./configure --enable-shared --enable-static
make
make install
# 然后再安装PIL库
wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
tar -zxvf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
rm -rf build
# 设置JPEG库的路径
vim setup.py :
JPEG_ROOT = libinclude("/usr/local")
python2.5 setup.py build
python2.5 setup.py install
# 把JPEG加入到系统库路径
echo '/usr/local/lib' >> /etc/ld.so.conf
ldconfig
# OK,完成
上述操作完成后就不会再报找不到 _imaging 的错误了。
别高兴太高,如果用到了freetype2,还会报_imagingft找不到。解决办法类似,先安装freetype2,在安装PIL里指定freetype2路径,将freetype2加到系统库路径中即可。
7 july 2011
13:25
I had some trouble getting the venerable Python Imaging Library (PIL) compiled
with the Freetype feature on Mac OS X 10.6. Doing a simple
build it with just the basic options. But if you need to generate Captchas and the like (with django-simple-captcha,
for example) you'll need the Freetype option, too.
In fact, OS X comes with Freetype2 installed (as part of the X11 package), just not in a location the PIL build script knows about. That is simple to fix, however:
The setup summary printed out at the end of the build should now say “FREETYPE2 support available”, which would mean this procedure worked as designed.
CODE: SELECT
ALL
Hi, the code above works just fine, but when I replace load_default() with truetype("Arial.ttf", 24) I get the error...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/PIL/ImageFont.py", line 218, in truetype
return FreeTypeFont(filename, size, index, encoding)
File "/usr/lib/python2.6/dist-packages/PIL/ImageFont.py", line 134, in __init__
self.font = core.getfont(file, size, index, encoding)
IOError: cannot open resource
...so it looks like it has a problem with opening the resource, which I'm thinking is something do with finding Arial.ttf. I'm not really knowledgeable on how linux handles fonts. I did look in the various fonts folders and found there is Ariel.ttf so I'm kind
of stuck about how to make things play nice.
Any ideas how I can get python to see my fonts? Is there any python code I could run to see which fonts it can see in Linux (I'm running Linux Mint 9)?
Thanks in advance.
leke
New Python User
Posts: 31
Joined: Sun Apr 11, 2010 10:40 am
Location: Oulu, Finland
Top
by mariostg »
Sun Dec 05, 2010 6:55 pm
Specify the full path
CODE: SELECT
ALL
# 需要先安装jpeg库
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7
CC="gcc -arch x86_64"
./configure --enable-shared --enable-static
make
make install
# 然后再安装PIL库
wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
tar -zxvf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
rm -rf build
# 设置JPEG库的路径
vim setup.py :
JPEG_ROOT = libinclude("/usr/local")
python2.5 setup.py build
python2.5 setup.py install
# 把JPEG加入到系统库路径
echo '/usr/local/lib' >> /etc/ld.so.conf
ldconfig
# OK,完成
上述操作完成后就不会再报找不到 _imaging 的错误了。
别高兴太高,如果用到了freetype2,还会报_imagingft找不到。解决办法类似,先安装freetype2,在安装PIL里指定freetype2路径,将freetype2加到系统库路径中即可。
Building PIL with Freetype2 on Snow Leopard
7 july 201113:25
I had some trouble getting the venerable Python Imaging Library (PIL) compiled
with the Freetype feature on Mac OS X 10.6. Doing a simple
pip installor
easy_installwill
build it with just the basic options. But if you need to generate Captchas and the like (with django-simple-captcha,
for example) you'll need the Freetype option, too.
In fact, OS X comes with Freetype2 installed (as part of the X11 package), just not in a location the PIL build script knows about. That is simple to fix, however:
$ cd ~/Downloads $ curl -LO http://effbot.org/downloads/Imaging-1.1.7.tar.gz $ tar -zxf Imaging-1.1.7.tar.gz $ cd Imaging-1.1.7 $ echo 'FREETYPE_ROOT = "/usr/X11/lib", "/usr/X11/include"' > setup_site.py $ python setup.py build
The setup summary printed out at the end of the build should now say “FREETYPE2 support available”, which would mean this procedure worked as designed.
CODE: SELECT
ALL
#!usr/bin/env python from PIL import Image, ImageDraw, ImageFont scribble = "Hello World" img = Image.new("RGB", (200,200)) canvas = ImageDraw.Draw(img) the_font = ImageFont.load_default() # truetype("Arial.ttf", 24) canvas.text((0,0), scribble, font=the_font) img.save(open("weather.png", "wb"), "PNG")
Hi, the code above works just fine, but when I replace load_default() with truetype("Arial.ttf", 24) I get the error...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/PIL/ImageFont.py", line 218, in truetype
return FreeTypeFont(filename, size, index, encoding)
File "/usr/lib/python2.6/dist-packages/PIL/ImageFont.py", line 134, in __init__
self.font = core.getfont(file, size, index, encoding)
IOError: cannot open resource
...so it looks like it has a problem with opening the resource, which I'm thinking is something do with finding Arial.ttf. I'm not really knowledgeable on how linux handles fonts. I did look in the various fonts folders and found there is Ariel.ttf so I'm kind
of stuck about how to make things play nice.
Any ideas how I can get python to see my fonts? Is there any python code I could run to see which fonts it can see in Linux (I'm running Linux Mint 9)?
Thanks in advance.
leke
New Python User
Posts: 31
Joined: Sun Apr 11, 2010 10:40 am
Location: Oulu, Finland
Top
Re:
Python, Linux and the PIL
by mariostg »
Sun Dec 05, 2010 6:55 pm
Specify the full path
CODE: SELECT
ALL
the_font = ImageFont.truetype("/usr/share/fonts/TTF/arial.ttf", 24)
相关文章推荐
- Python 的PIL,可以解决ImportError The _imagingft C module is not installed
- 用pil产生验证码出现:ImportError: The _imagingft C module is not installed
- 用pil产生验证码出现:ImportError: The _imagingft C module is not installed
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- window下Django第三方APP调用PIL生成验证码出现ImportError: The _imagingft C module is not installed解决
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- 用pil产生验证码出现:ImportError: The _imagingft C module is not installed
- 用pil产生验证码出现:ImportError: The _imagingft C module is not installed
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- PIL写入字体出现ImportError:The _imagingft C module is not installed 错误的解决方法
- PIL “The _imagingft C module is not installed” 错误补救
- Python: The _imagingft C module is not installed错误的解决
- Pillow-PIL的完全Fok替代库--完美解决报错The _imagingft C module is not installed的解决方案
- PIL写入字体出现“ImportError: The _imagingft C module is not installed”的解决方法
- Python: The _imagingft C module is not installed错误的解决
- 解决Windows下PIL库的"The _imagingft C module is not installed"错误
- Windows系统下,报错The _imagingft C module is not installed
- 解决PIL “decoder jpeg not available” 和 “ImportError: The _imaging C module is not installed”的问题