1

I am trying to upload and resize an image using PIL on Django 1.4.1.

I have tried this: https://stackoverflow.com/a/10109941/356875

but nothing changed.

I use virtualenv and when I do pip install -I PIL I get this error:

running install_lib

creating /usr/lib/python2.7/site-packages

error: could not create '/usr/lib/python2.7/site-packages': Permission denied

so I have to sudo pip install -I PIL which works and gives me this:

   PIL 1.1.7 SETUP SUMMARY
    --------------------------------------------------------------------
    version       1.1.7
    platform      linux2 2.7.3 (default, Sep 26 2012, 21:51:14)
                  [GCC 4.7.2]
    --------------------------------------------------------------------
    *** TKINTER support not available
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    *** FREETYPE2 support not 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/pildriver.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/pilfile.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/pilfont.py from 644 to 755

    changing mode of /usr/local/bin/pildriver.py to 755
    changing mode of /usr/local/bin/pilprint.py to 755
    changing mode of /usr/local/bin/pilfile.py to 755
    changing mode of /usr/local/bin/pilconvert.py to 755
    changing mode of /usr/local/bin/pilfont.py to 755
Successfully installed PIL
Cleaning up...

However when I try to save a model I get this error:

IOError at /admin/main/pagecategory/21/

decoder jpeg not available

Request Method:     POST
Request URL:    http://localhost:8000/admin/main/pagecategory/21/
Django Version:     1.4.1
Exception Type:     IOError
Exception Value:    

decoder jpeg not available

Exception Location:     /home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/PIL/Image.py in _getdecoder, line 385
Python Executable:  /home/chris/.virtualenvs/holistic/bin/python
Python Version:     2.7.3
Python Path:    

['/home/chris/Dropbox/workspace/holistic',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg',
 '/home/chris/.virtualenvs/holistic/lib/python2.7',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/plat-linux2',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/lib-tk',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages',
 '/home/chris/.virtualenvs/holistic/lib/python2.7/site-packages/PIL',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/local/lib/python2.7/dist-packages/PIL']

Server time:    Fri, 4 Jan 2013 12:35:58 +0200

What am I doing wrong?

(PS: exact same configuration works fine on my remote hosting linux server)

EDIT: I dpasted another detailed output Thank you. http://dpaste.com/867770/

4

1 回答 1

0

activate您的/workon脚本可能有问题。尝试传递您的 virtualenv 的pip绝对路径,例如:

$ /tmp/myenv/bin/pip install -I PIL

为了检查 PIL 是否安装在您的 virtualenv 中,请执行以下操作:

$ /tmp/myenv/bin/python -c 'import PIL'

如果它没有给您任何错误,则它已正确安装。

也许你的问题和这个一样:默认是 System PIP 而不是 virtualenv PIP?

于 2013-01-06T22:23:44.350 回答