使用Ubuntu 13.10,蟒蛇2.7.5:當升級Python圖像庫(PIL),它告訴我 「JPEG支持不可用」
>>> import _imaging, Image
>>> from PIL import Image, ImageDraw, ImageFilter, ImageFont
>>> 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/lib/python2.7/dist-packages/PIL/ImageFont.py", line 218, in truetype
return FreeTypeFont(filename, size, index, encoding)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFont.py", line 134, in __init__
self.font = core.getfont(file, size, index, encoding)
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFont.py", line 34, in __getattr__
raise ImportError("The _imagingft C module is not installed")
**ImportError: The _imagingft C module is not installed**
>>>
那麼,爲什麼會發生這種情況?我該如何解決它?我跟着我發現在this thread底部以下說明:
pip uninstall PIL
apt-get install libjpeg-dev
apt-get install libfreetype6-dev
apt-get install zlib1g-dev
apt-get install libpng12-dev
pip install PIL --upgrade
但同時升級PIL,看看我看到:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1]
--------------------------------------------------------------------
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG/ZIP) support not available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
是否正常支持所有這些項目不可用?我該如何解決這個問題?
這可能值得看看AskUbuntu而不是這裏。例如,[這個問題](http://askubuntu.com/questions/156484/how-do-i-install-python-imaging-library-pil)是一個類似的,但Ubuntu的具體問題(儘管它也是一個有點過時了,因爲它似乎仍然建議PIL而不是Pillow)。 – abarnert
同時,如果Ubuntu有一個Pillow軟件包(不管是'python-imaging'是否已經更新,或者是一個名爲'python-pillow'的新軟件包),你可能想使用它來代替'pip'(假設你'重新安裝到默認的Ubuntu Python中)。 – abarnert
而Ubuntu _does_有一個Pillow包:在你的Ubuntu版本中,'python-imaging' 1.1.7 + 2.0.0-1ubuntu1是Pillow 2.0.0。 (奇怪的版本號是填充其他各種認爲他們需要PIL 1.1.7的軟件包的先決條件。)所以,就這麼做。 – abarnert