python PIL ImportError: The _imagingft C module is not installed
来源:互联网 发布:泰安焦点网络待遇 编辑:程序博客网 时间:2024/05/16 06:35
# 需要先安装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 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 pip install
or easy_install
will 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
Re: Python, Linux and the PIL
- CODE: SELECT ALL
the_font = ImageFont.truetype("/usr/share/fonts/TTF/arial.ttf", 24)
- python PIL ImportError: The _imagingft C module is not installed
- 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 错误的解决方法
- PIL “The _imagingft C module is not installed” 错误补救
- ImportError: The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- python中PIL库在使用时出现The _imagingft C module is not installed错误
- The _imagingft C module is not installed
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- 解决Windows下PIL库的"The _imagingft C module is not installed"错误
- ImportError:The _imagingft C module is not installed 错误的解决方法
- window下Django第三方APP调用PIL生成验证码出现ImportError: The _imagingft C module is not installed解决
- Pillow-PIL的完全Fok替代库--完美解决报错The _imagingft C module is not installed的解决方案
- Python: The _imagingft C module is not installed错误的解决
- 解决PIL “decoder jpeg not available” 和 “ImportError: The _imaging C module is not installed”的问题
- 在linux shell中使用ftp命令来实现自动登陆、上传与下载
- 将一张表的字段根据条件更新到另一张表的一个字段中去
- cocos2d 安装 和 卸载
- c++输出格式控制
- Eclipse导入到web项目没有run on server
- python PIL ImportError: The _imagingft C module is not installed
- 我的定投计划
- 使用Sqlserver事务发布实现数据同步
- 错排公式
- poj 3728 tarjan+带权路径并查集
- Windows Phone 7 The database encryption mode is invalid.
- 腾讯抄袭之史 当之无愧的剽窃之王【最近剽窃 qq空间时间轴 VS 钥匙网】
- drupal count condition addExpression
- 关于android 适配不同分辨率的记录