Ubuntu 11.04: Installing PIL into a virtualenv wit

2019-03-17 09:53发布

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.

1条回答
放我归山
2楼-- · 2019-03-17 10:44

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)

查看更多
登录 后发表回答