【问题标题】:Linux Mint 14 & python PIL gives <decoder jpeg not available> errorLinux Mint 14 & python PIL 给出 <decoder jpeg not available> 错误
【发布时间】:2013-01-04 11:10:28
【问题描述】:

我正在尝试在 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/

【问题讨论】:

  • 我认为你需要使用-E &lt;your_env_dir&gt;选项安装。
  • 我觉得奇怪的是pipvirtualenv 下运行时尝试安装在/usr/lib/python2.7/site-packages 中。它不应该安装在/home/chris/.virtualenvs/holistic/lib/pyhon2.7/site-packages 中吗?您是否使用了正确的pip 来安装PIL?另请参阅documentation
  • @Rohan 这就是我得到的:pip install -E holistic PIL Usage: pip install [OPTIONS] PACKAGE_NAMES... no such option: -E @Evert 我总是使用相同的点子(在我完成了workon &lt;my_env&gt; 命令之后。所有东西都安装在我的虚拟环境中。PIL 是到目前为止唯一的问题)
  • 我对 Pillow 有同样的问题(PIL 插入)。说 JPEG 在配置时没问题,但是当我尝试加载 JPEG 时会摔倒。

标签: python django python-imaging-library virtualenv


【解决方案1】:

您的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?

【讨论】:

    猜你喜欢
    • 2011-04-02
    • 2014-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多