Linux Mint 14&amp; python PIL给出<decoder jpeg =“”not =“”available =“”> error </decoder>

时间:2013-01-04 11:10:28

标签: python django python-imaging-library virtualenv

我正在尝试使用Django 1.4.1上的PIL上传和调整图像大小。

我试过这个:https://stackoverflow.com/a/10109941/356875

但没有改变。

我使用virtualenv,当我pip install -I PIL时,我收到此错误:

running install_lib

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

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

所以我必须sudo pip install -I PIL哪个有效并且给我这个:

   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...

然而,当我尝试保存模型时,我收到此错误:

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

我做错了什么?

(PS:完全相同的配置在我的远程主机linux服务器上正常工作)

编辑:我再次详细输出了谢谢。 http://dpaste.com/867770/

1 个答案:

答案 0 :(得分:0)

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

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

为了检查你的virtualenv中是否安装了PIL,请执行:

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

如果没有错误,则表示已正确安装。

也许您的问题与此相同:System PIP instead of virtualenv PIP by default?