title: PIL will not import the _imaging C module: "*** The _imaging C module is not installed"
body: <p>A bit of background from the PIL setup.py build:</p>
  
  <pre><code>--------------------------------------------------------------------
  PIL 1.1.7 SETUP SUMMARY
  --------------------------------------------------------------------
  version       1.1.7
  platform      linux2 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
                [GCC 4.3.3]
  --------------------------------------------------------------------
  *** TKINTER support not available
  --- JPEG support available
  --- ZLIB (PNG/ZIP) support available
  --- FREETYPE2 support available
  *** LITTLECMS support not available
  --------------------------------------------------------------------
  </code></pre>
  
  <p>This is on an Ubuntu 9.04 installation.</p>
  
  <p>I only need PIL to enable Django to upload and resize various images (of different formats).  Unfortunately, it can't currently process JPEGs.  After performing PIL's selftest.py, it came up with this:</p>
  
  <pre><code>*** The _imaging C module is not installed
  </code></pre>
  
  <p>I tried importing Image and _imaging using the python -v interpreter (which both worked)...</p>
  
  <pre><code>&gt;&gt;&gt; from PIL import Image
  import PIL # directory PIL
  # PIL/__init__.pyc matches PIL/__init__.py
  import PIL # precompiled from PIL/__init__.pyc
  # PIL/Image.pyc matches PIL/Image.py
  import PIL.Image # precompiled from PIL/Image.pyc
  </code></pre>
  
  <p>[continues successfully for quite a while]</p>
  
  <pre><code>&gt;&gt;&gt; import _imaging
  dlopen("/usr/local/lib/python2.6/dist-packages/PIL/_imaging.so", 2);
  import _imaging # dynamically loaded from /usr/local/lib/python2.6/dist-packages/PIL/_imaging.so
  </code></pre>
  
  <p>So _imaging is available when using the python interpreter, but for some reason isn't being imported properly in other instances.</p>
  
  <p>I've been looking for solutions to this problem for the last several hours and haven't come any closer to finding one.  Am I missing something stupidly obvious?  Or are there any ideas as to why it isn't working?</p>
  
  <p>Thanks in advance!</p>
  
  <p><em>Also: I am aware of <a href="http://effbot.org/zone/pil-imaging-not-installed.htm" rel="nofollow">http://effbot.org/zone/pil-imaging-not-installed.htm</a> but that only demonstrates the error and provides no solution.</em></p>
  
  <p><strong>EDIT:</strong> I've been snooping around and it appears that importing _imagingmath is the problem.  I did python -vv selftest.py to see where it was breaking, and this is how it happened:</p>
  
  <pre><code>dlopen("/usr/local/lib/python2.6/dist-packages/PIL/_imagingmath.so", 2);
  import _imagingmath # dynamically loaded from /usr/local/lib/python2.6/dist-packages/PIL/_imagingmath.so
  *** The _imaging C module is not installed
  # clear __builtin__._
  [etc. etc. etc.]
  </code></pre>