Programing

Python : _imagingft C 모듈이 설치되지 않았습니다.

lottogame 2020. 10. 31. 09:09
반응형

Python : _imagingft C 모듈이 설치되지 않았습니다.


나는 인터넷에 게시 된 많은 솔루션을 시도했지만 작동하지 않습니다.

>>> import _imaging
>>> _imaging.__file__
'C:\\python26\\lib\\site-packages\\PIL\\_imaging.pyd'
>>>

따라서 시스템은 _imaging을 찾을 수 있지만 여전히 트루 타입 글꼴을 사용할 수 없습니다.

from PIL import Image, ImageDraw, ImageFilter, ImageFont


im = Image.new('RGB', (300,300), 'white')
draw = ImageDraw.Draw(im)
font = ImageFont.truetype('arial.ttf', 14)
draw.text((100,100), 'test text', font = font)

이 오류가 발생합니다.

ImportError: The _imagingft C module is not installed

File "D:\Python26\Lib\site-packages\PIL\ImageFont.py", line 34, in __getattr__
  raise ImportError("The _imagingft C module is not installed")

설치된 PIL이 libfreetype없이 컴파일되었습니다.

여기에서 사전 컴파일 된 PIL 설치 프로그램 (libfreetype으로 컴파일 됨)을 얻을 수 있습니다 (그리고 다른 많은 사전 컴파일 된 Python C 모듈).

http://www.lfd.uci.edu/~gohlke/pythonlibs/


Ubuntu에서는 PIL을 컴파일하기 전에 libfreetype-dev가 설치되어 있어야합니다.

$ sudo apt-get install libfreetype6-dev
$ sudo -s
\# pip uninstall pil
\# pip install pil

추신! pip install을 sudo로 실행하면 일반적으로 대부분의 Ubuntu 버전에서 / usr / local / lib에 패키지가 설치됩니다. 대신 사용자가 소유 한 경로의 가상 환경 (virtualenv 또는 venv)에 Pil를 설치하는 것을 고려할 수 있습니다.

API 호환 가능하다고 생각하는 pil 대신 pillow 설치를 고려할 수도 있습니다 : https://python-pillow.org .


다음은 Ubuntu 14.04.1 64 비트에서 저에게 효과적이었습니다.

sudo apt-get install libfreetype6-dev

그런 다음 virtualenv에서 :

pip uninstall pillow
pip install --no-cache-dir pillow

CentOS 6 (및 아마도 다른 rpm 기반) 용 솔루션 :

yum install freetype-devel libjpeg-devel libpng-devel

pip uninstall pil Pillow
pip install pil Pillow

OS X에서는 문제를 해결하기 위해 이렇게했습니다.

pip uninstall PIL
ln -s /usr/X11/include/freetype2 /usr/local/include/
ln -s /usr/X11/include/ft2build.h /usr/local/include/
ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/
ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/libfreetype.dylib
pip install PIL

기본적으로 PIL을 설치하기 전에 freetype을 설치해야합니다.

OS X에서 Homebrew사용하는 경우 다음과 같은 문제가 있습니다.

brew remove pil
brew install freetype
brew install pil

Ubuntu 12.10에서 작동 :

sudo pip uninstall PIL
sudo apt-get install libfreetype6-dev
sudo apt-get install python-imaging

OS X의 경우 (10.6을 실행 중이지만 다른 사용자를 위해 작동해야 함) 이 게시물 의 조언을 사용하여이 오류를 해결할 수있었습니다 . 기본적으로 몇 가지 종속성을 설치 한 다음 PIL을 다시 설치해야합니다.


For me none of the solutions posted here so far has worked. I found another solution here: http://codeinthehole.com/writing/how-to-install-pil-on-64-bit-ubuntu-1204/

First install the dev packages:

$ sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev

Then create some symlinks:

$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

Afterwards PIL should compile just fine:

$ pip install PIL --upgrade

The followed works on ubuntu 12.04:

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

when your see "-- JPEG support avaliable" that means it works.

But, if it still doesn't work when your edit your jpeg image, check the python path!!
My python path missed '/usr/local/lib/python2.7/dist-packages/PIL-1.1.7-py2.7-linux-x86_64.egg/', so I edit the ~/.bashrc add the following code to this file:

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/dist-packages/PIL-1.1.7-py2.7-linux-x86_64.egg/

then, finally, it works!!


Ubuntu 11.10 installs zlib and freetype2 libraries following the multi-arch spec (e.g. /usr/lib/i386-linux-gnu). You may use PIL setup environment variables so it can find them. However it only works on PIL versions beyond the pil-117 tag.

export PIL_SETUP_ZLIB_ROOT=/usr/lib/i386-linux-gnu
export PIL_SETUP_FREETYPE_ROOT=/usr/lib/i386-linux-gnu
pip install -U PIL

Since your multi-arch path may be different (x86-64), it's preferable to install the -dev packages and use pkg-config to retrieve the correct path.

pkg-config --variable=libdir zlib
pkg-config --variable=libdir freetype2

Another way given by Barry on Pillow's setup.py is to use dpkg-architecture -qDEB_HOST_MULTIARCH to obtain the proper library directory suffix.

See https://bitbucket.org/effbot/pil-2009-raclette/issue/18


I used homebrew to install freetype and I have the following in /usr/local/lib:

libfreetype.6.dylib libfreetype.a libfreetype.dylib

But the usual:

pip install pil

Does not work for me, so I used:

pip install http://effbot.org/downloads/Imaging-1.1.6.tar.gz


In my Mac, the following steps in terminal works:

$ brew install freetype
$ sudo pip uninstall pil
$ sudo pip install pillow

hopes it works for you. Good luck!


【solved】
In my ubuntu12.04, after I installed python-imaging using apt-get, it works.

참고URL : https://stackoverflow.com/questions/4011705/python-the-imagingft-c-module-is-not-installed

반응형