title: PIL encoder jpeg not available
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7648200/pip-install-pil-e-tickets-1-no-jpeg-png-support">pip install PIL -E TICKETS-1 - No JPEG/PNG support</a>  </p>
  </blockquote>
  
  
  
  <p>I'm working on a picture cropper, and I'm having trouble with my form validation. The form is validated when uploading a GIF picture, but any other format I try raises the following exception:</p>
  
  <pre><code>Upload a valid image. The file you uploaded was either not an image or a corrupted image.
  </code></pre>
  
  <p><strong>Form</strong></p>
  
  <pre><code>&lt;form enctype="multipart/form-data" method="post" action="/pic/"&gt;{% csrf_token %}
      {{ form.as_p }}
      &lt;p&gt;&lt;input type="submit" value="View uploaded image"&gt;&lt;/p&gt;
      &lt;input type="hidden" name="stage" value="crop"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>if request.method == 'POST':
          form = ProfilePicForm(request.POST, request.FILES)
          if form.is_valid():
              *do stuff*
          else:
              logger.debug('Form errors == [%s]' % form.errors)
  </code></pre>
  
  <p>I have installed libjpeg-dev(using apt-get) before installing PIL(using easy_install). At first, I thought this might be due to an incorrect installation of either libjpeg-dev or PIL, but would the problem persists for other formats like png? This problem does in fact occur for png images as well. I'm not getting a jpeg decoder problem, so I'm thinking it's not that, but I'm not sure. Also, I'm using the django development server.</p>
  
  <hr>
  
  <h1><strong>Update</strong></h1>
  
  <p>I decided to try a reinstall of PIL. I deleted my PIL install folder 
  <code>/usr/local/lib/python2.7/dist-packages/PIL</code>
   and my PIL.pth file (in the same dist-packages folder). I ran the setup.py script using <code>sudo python setup.py install</code>. I then ran the selftest.py script, and it fails on the first test:</p>
  
  <pre><code>--------------------------------------------------------------------
  PIL 1.1.7 TEST SUMMARY 
  --------------------------------------------------------------------
  Python modules loaded from ./PIL
  Binary modules loaded from ./PIL
  --------------------------------------------------------------------
  --- PIL CORE support ok
  *** TKINTER support not installed
  *** JPEG support not installed
  *** ZLIB (PNG/ZIP) support not installed
  *** FREETYPE2 support not installed
  --- LITTLECMS support ok
  --------------------------------------------------------------------
  Running selftest:
  *****************************************************************
  Failure in example:
  try:
   _info(Image.open(os.path.join(ROOT, "Images/lena.jpg")))
  except IOError, v:
   print v
  from line #24 of selftest.testimage
  Expected: ('JPEG', 'RGB', (128, 128))
  Got: decoder jpeg not available
  1 items had failures:
     1 of  57 in selftest.testimage
  ***Test Failed*** 1 failures.
  *** 1 tests of 57 failed.
  </code></pre>
  
  <p>I'm not sure how to get PIL to work with the unsupported modules listed above. I can verify that I have zlib1g-dev, libfreetype6-dev, liblcms1-dev and libjpeg62-dev, and the libraries themselves installed on my system because when I try to install them with apt-get, it says I already have the latest version.</p>