WebFaction
Community site: login 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 13 May '12, 22:52

sterneberg
1124
accept rate: 0%


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

permanent link

answered 13 May '12, 23:31

waynek
4254
accept rate: 27%

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

(18 May '12, 05:14) sterneberg

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.

permanent link

answered 18 May '12, 05:31

iliasr ♦♦
2.2k14
accept rate: 34%

edited 18 May '12, 05:31

Your answer
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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×17
×12
×2
×1

question asked: 13 May '12, 22:52

question was seen: 6,070 times

last updated: 18 May '12, 05:31

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM