-5

I have spent hours now trying to figure this out.

I do the following:

sudo apt-get install python-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install libfreetype6 libfreetype6-dev
mkvirtualenv -p python2.7 --no-site-packages foobar
pip install PIL

Whenever I try to upload an image in my django-cms website I get an error message.

2
  • 2
    The least you can do is post the error message... May 26, 2011 at 13:07
  • The error message is: "Upload a valid image. The file you uploaded was either not an image or a corrupted image." While the OP did not phrase this as question, this is a common problem.
    – claymation
    Jul 4, 2012 at 2:15

1 Answer 1

16

I've ran into the same issue while trying to use Django & Virtualenv - I couldn't upload images and after some research everything pointed towards PIL. I did try to reinstall the package but even with all the required libraries uploaded PIL still wouldn't support JPGs and PNGs.

Seems that Ubuntu peeps decided to moved the location of the libraries around (according to this fix: http://ubuntuforums.org/showpost.php?p=10804763&postcount=2).

My solution:

  1. Make sure you have all the libraries installed.

    sudo apt-get install libjpeg-dev libjpeg62 libjpeg62-dev zlib1g-dev libfreetype6 libfreetype6-dev

  2. Install Pillow, which is a saner package of PIL.

    pip install pillow (while in your virtualenv)

5
  • 2
    How did you make Django work with Pillow instead of PIL? I get: "To use ImageFields, you need to install PIL.."
    – Ron Cohen
    Jan 17, 2012 at 11:38
  • 3
    @Ron Cohen: It's a drop in replacement - just a slightly differently packaged PIL.
    – stricjux
    Jan 19, 2012 at 16:57
  • I get the following error when trying to install the libraries with apt-get: libjpeg-turbo8-dev : Conflicts: libjpeg62-dev but 6b1-2ubuntu1 is to be installed. Any ideas? Im using ubuntu 12.04 Jun 21, 2012 at 19:24
  • @JuanEnriqueMuñozZolotoochin Remove libjpeg-turbo8-dev? Did that help?
    – stricjux
    Jun 27, 2012 at 12:55
  • HUGE thanks. that worked. the moved path is a nice touch Aug 26, 2012 at 16:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.