-
Notifications
You must be signed in to change notification settings - Fork 0
/
389 PIL载入字体出错:ImportError The _imagingft C mo.html
24 lines (23 loc) · 15.6 KB
/
389 PIL载入字体出错:ImportError The _imagingft C mo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
<head>
<title>389 PIL载入字体出错:ImportError: The _imagingft C module is not installed</title>
<basefont face="Tahoma" size="2" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="exporter-version" content="Evernote Windows/270217 (zh-CN); Windows/6.1.7600;"/>
<style>
body, td {
font-family: Tahoma;
font-size: 10pt;
}
</style>
</head>
<body>
<a name="2093"/>
<h1>389 PIL载入字体出错:ImportError: The _imagingft C module is not installed</h1>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">用PIL生成文字图,载入字体出现错误:ImportError: The _imagingft C module is not installed</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">搜索得知,这个是由于安装的PIL版本没有编译freetype导致的,解决方法是可以自行编译,但不会,也太麻烦。</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">有个网友给出了他找到的一个编译好的PIL,安装后可用。<br>
地址是:<a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/" style="color: rgb(0, 68, 153); text-decoration: none;" target="_blank">http://www.lfd.uci.edu/~gohlke/pythonlibs/</a>,找到PIL,选择对应的版本下载。我这里安装的是 Pillow-2.0.0.win32-py2.7 。<br>
另一个下载地址:<a href="https://pypi.python.org/pypi/Pillow/2.0.0" style="color: rgb(0, 68, 153); text-decoration: none;" target="_blank">https://pypi.python.org/pypi/Pillow/2.0.0</a><br>
虽然解决了字体问题,但是出现了另一个错误: SAVE[format.upper()] # unknown format<br>
无法保存图片,换回官方版的PIL可以正常保存图片,但又在载入字体时出错。</p><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">又在网上搜索,找不同版本的PIL测试,总会出现不同的问题。在stackoverflow.com上看到有个苹果用户在另一个求助帖里回复他通过把</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">from</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">PIL</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">import</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">Image</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(51, 51, 51) !important;">,</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">ImageFont</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">修改为</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">import</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">Image</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(51, 51, 51) !important;">,</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">ImageFont</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">解决了一个问题。我本来写的导入库的方式就是</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">import</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">Image</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">ImageFont</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">ImageDraw</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">,抱着试试看的心态改成了</p><div style="text-align: left; box-sizing: border-box; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 626px; padding: 0px; margin: 10px 0px; font-family: Monaco, MonacoRegular, 'Courier New', monospace; border: 1px solid rgb(153, 153, 153) !important; text-shadow: none !important; background-color: rgb(253, 253, 253) !important; color: rgb(51, 51, 51); float: none; clear: both; font-size: 12px !important; line-height: 15px !important; height: auto;"><div style="border: 0px; padding: 0px; margin: 0px; width: 624px; overflow: hidden; max-height: 500px; position: relative; z-index: 1; background-position: 0px 50%;"><table style="border: none !important; padding: 0px !important; margin: 0px 0px 0px -18px !important; background-image: none !important; width: auto !important; border-spacing: 0px !important; border-collapse: collapse !important;"><tbody><tr style="padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background-position: 0px 50%;"><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; background-color: rgb(223, 239, 255) !important; color: rgb(84, 153, 222) !important;"><div style="border: 0px; padding: 0px; margin: 0px; background-position: 0px 50%;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;">1</div></div></td><td style="vertical-align: top !important; border: 0px; padding: 0px !important; margin: 0px !important; width: 625px; background-position: 0px 50%;"><div style="background-image: none !important; border: none !important; padding: 0px; margin: 0px; color: rgb(0, 0, 0); white-space: pre; overflow: visible;"><div style="font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; font-size: inherit !important; line-height: inherit !important; height: inherit !important; background-position: 0px 50%;"><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">from</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">PIL</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(0, 78, 208) !important;">import</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">Image</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(51, 51, 51) !important;">,</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">ImageFont</span><span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important; color: rgb(51, 51, 51) !important;">,</span> <span style="font-family: inherit; font-size: inherit !important; line-height: inherit !important; height: inherit !important;">ImageDraw</span></div></div></td></tr></tbody></table></div></div><p style="margin: 0px; padding: 5px 0px; line-height: 22px; color: rgb(51, 51, 51); font-family: 'Microsoft YaHei', Tahoma, Arial; font-size: 14px; background-color: rgb(255, 255, 255);">,结果 SAVE[format.upper()] # unknown format 的错误没有出现了!小挫折竟然就这样解决了!</p><br></div>
</div></body></html>