ImportError: No module named ImageFont
<p>I'm using the chemlab library for the first time. I'm trying to run some of the example programs but I keep getting the following error message:</p>

<blockquote>
  <p>import ImageFont  # From PIL</p>
  
  <p>ImportError: No module named ImageFont</p>
</blockquote>

<p>Here is the code to one of the basic examples (<a href="https://github.com/chemlab/chemlab/blob/master/examples/nacl.py" rel="nofollow">https://github.com/chemlab/chemlab/blob/master/examples/nacl.py</a>):</p>

<pre><code>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)
</code></pre>

<p>I've tried installing ImageFont, PIL and Pillow via pip (Pillow was the only one that actually installed) but no luck.</p>

<p>Install <code>PIL</code>:</p>

<pre><code>pip install pillow
</code></pre>

<p>Correct import for <code>ImageFont</code> is:</p>

<pre><code>from PIL import ImageFont
</code></pre>

<p>Here is an example of <code>ImageFont</code>:</p>

<pre><code>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)
</code></pre>

python importerror