title: Getting Django to recognize PIL JPEG support
body: <p>I am running <code>Django 1.4</code> and <code>PIL 1.1.7</code> in a <code>virtualenv</code> managed with <code>pip</code>. Whenever I upload a JPEG file via my admin interface, I get the following error: <code>Upload a valid image. The file you uploaded was either not an image or a corrupted image.</code> </p>
  
  <p>As many Ubuntu users have reported, on installation, PIL erronously looked in <code>/usr/lib/</code> for <code>libjpeg</code>, while its true location was in <code>/usr/lib/i386-linux-gnu/</code>. That's taken care of; I followed the answers in these posts:</p>
  
  <p><a href="https://stackoverflow.com/questions/7606614/django-imagefield-upload-a-valid-image-the-file-you-uploaded-was-either-not-an">Django ImageField &quot;Upload a valid image. The file you uploaded was either not an image or a corrupted image.&quot;</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1402002/why-cant-i-upload-jpg-files-to-my-django-app-via-admin">Why can&#39;t I upload jpg files to my Django app via admin/?</a></p>
  
  <p>Now the final output of installation looks as follows:</p>
  
  <hr>
  
  <pre><code>PIL 1.1.7 SETUP SUMMARY
  --------------------------------------------------------------------
  version       1.1.7
  platform      linux2 2.7.3 (default, Apr 20 2012, 22:44:07)
                [GCC 4.6.3]
  --------------------------------------------------------------------
  --- TKINTER support available
  --- JPEG support available
  --- ZLIB (PNG/ZIP) support available
  --- FREETYPE2 support available
  *** LITTLECMS support not available
  --------------------------------------------------------------------
  To add a missing option, make sure you have the required
  library, and set the corresponding ROOT variable in the
  setup.py script.
  
  To check the build, run the selftest.py script.
  changing mode of build/scripts-2.7/pilfile.py from 644 to 755
  changing mode of build/scripts-2.7/pilfont.py from 644 to 755
  changing mode of build/scripts-2.7/pilconvert.py from 644 to 755
  changing mode of build/scripts-2.7/pilprint.py from 644 to 755
  changing mode of build/scripts-2.7/pildriver.py from 644 to 755
  
  changing mode of /usr/local/bin/pilfile.py to 755
  changing mode of /usr/local/bin/pilfont.py to 755
  changing mode of /usr/local/bin/pilconvert.py to 755
  changing mode of /usr/local/bin/pilprint.py to 755
  changing mode of /usr/local/bin/pildriver.py to 755
  Successfully installed PIL
  </code></pre>
  
  <hr>
  
  <p>However, Django <em>still</em> doesn't allow me to upload anything but BMP files, which is not acceptable for this project. Unlike the user in the second link, I'm not using Apache, so my problem is probably not related. My suspicion is that Django is still using an old installation of PIL. The problem is that I don't know where it could be getting it from. The files in <code>~/.virtualenvs/project/local/lib/python2.7/site-packages</code> seem up-to-date to me. Any ideas?</p>
  
  <p>EDIT 1: Also note that I have tried logging out and logging back in the admin, as well as installing <code>pillow</code>, as in this post: <a href="https://stackoverflow.com/questions/9271267/uploading-a-jpeg-image-via-django-displays-error?rq=1">Uploading a JPEG image via Django displays error</a></p>