login community faq

Hello everybody!
I'm a Django newbie. I have a Django website with a model that has an ImageField. Whenever I try to upload a .png or .jpg image I get the message: "Upload a valid image. The file you uploaded was either not an image or a corrupted image."

According to this thread, it is because PIL (Python Imaging Library) cannot find the system libraries needed. The thread mentions two ways to fix this. The first way involves editing setup.py for PIL and I couldn't get it to work. The other way involves creating symboling links to the libraries so the installer finds them. This I cannot do because I don't have sudo rights. I found the libraries on Webfaction's server and the commands would be:

sudo ln -s /usr/lib64/libfreetype.so /usr/lib/
sudo ln -s /usr/lib64/libz.so /usr/lib/
sudo ln -s /usr/lib64/libjpeg.so /usr/lib/

Does anyone know of a third solution, or do I need to open a ticket?

Thanks in advance!

asked May 13 '12 at 22:52

sterneberg's gravatar image

sterneberg
112


Hi sterneberg,

Installing third party libraries on your WebFaction hosted sites is quite straightforward. To install a package to your home directory, simply follow these steps:

  1. Make sure that a library directory exists for the version of Python you're using. E.g. mkdir -p $HOME/lib/python2.7
  2. Use easy_install or pip to install the package. E.g. to use easy_install to install PIL simply run easy_install-2.7 PIL (remember to replace 2.7 with whatever Python version you're using.)

For more information please see the docs at:

http://docs.webfaction.com/software/python.html#installing-python-packages

If you have any other questions please don't hesitate to ask.

Regards,

Wayne K

WebFaction Support

answered May 13 '12 at 23:31

waynek's gravatar image

waynek ♦♦
954

Hi Wayne,

Thank you for the response.

PIL is installed and works for BMP images, but not for PNG and JPG, because PIL could not find the system libraries during installation. This is a bug in the PIL software that (according to my understanding) must be remedied using one of the methods I mentioned.

Using BMP images only on the website would make load times a lot longer, so I'm hoping to avoid it.

Thanks again

(May 18 '12 at 05:14) sterneberg sterneberg's gravatar image

Try installing PIL according to the community question How to install PIL with truetype support. It should find the JPEG libraries and verify it when running the python2.7 selftest.py command.

answered May 18 '12 at 05:31

iliasr's gravatar image

iliasr ♦♦
7013

edited May 18 '12 at 05:31

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×641
×14
×8
×2
×1

Asked: May 13 '12 at 22:52

Seen: 1,074 times

Last updated: May 18 '12 at 05:31

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited