2016-10-08 5 views
1

저는 처음으로 chemlab 라이브러리를 사용하고 있습니다. 내가 예제 프로그램의 일부를 실행하기 위해 노력하고있어하지만 다음과 같은 오류 메시지가 계속 : 나 'ImportError : ImageFont라는 모듈이 없습니다.

from chemlab.core import Atom, Molecule, crystal 
from chemlab.graphics import display_system 

# Molecule templates 
na = Molecule([Atom('Na', [0.0, 0.0, 0.0])]) 
cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])]) 

s = crystal([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]], # Fractional Positions 
      [na, cl], # Molecules 
      225, # Space Group 
      cellpar = [.54, .54, .54, 90, 90, 90], # unit cell parameters 
      repetitions = [5, 5, 5]) # unit cell repetitions in each direction 

display_system(s) 

: 여기

import ImageFont # From PIL

ImportError: No module named ImageFont

은 기본 예제 중 하나에 코드 (https://github.com/chemlab/chemlab/blob/master/examples/nacl.py)입니다 핏을 통해 ImageFont, PIL 및 Pillow를 설치하려고 시도했지만 (베개는 실제로 설치 한 유일한 것이었지만) 운이 없었습니다.

+0

를 설치하지 않은 :

여기
from PIL import ImageFont 

ImageFont의 예입니다? 해당 오류와 관련된 질문을 편집하십시오. –

+0

전체 스택 추적을 표시하십시오. –

답변

1

PIL 설치 : ImageFont에 대한

pip install pillow 

올바른 가져 오기입니다 : 왜 ImageFont 및 PIL은

from PIL import ImageFont, ImageDraw 

draw = ImageDraw.Draw(image) 

# use a bitmap font 
font = ImageFont.load("arial.pil") 

draw.text((10, 10), "hello", font=font) 

# use a truetype font 
font = ImageFont.truetype("arial.ttf", 15) 

draw.text((10, 25), "world", font=font)