【问题标题】:decoder jpeg not available: django with apache2解码器 jpeg 不可用:django with apache2
【发布时间】:2026-01-19 05:45:02
【问题描述】:

当我尝试使用简单的代码时

        time_created = time.time()
        tempPath = 'user_image/'+ str(request.user.id)+'/'+str(time_created)+'/'
        print tempPath
        path = default_storage.save(tempPath+'original.jpg', ContentFile(content_image.read()))
        tmp_file = os.path.join(settings.MEDIA_ROOT, path) #this line gives error
        image = open(tmp_file) 

它给了我错误:解码器 jpeg 不可用

这是我为解决它所做的: http://www.answermysearches.com/fixing-pil-ioerror-decoder-jpeg-not-available/320/

我正在使用python2.7 和 Imaging-1.1.7

按照上面的链接,当我在终端上运行 python selftest.py 时,我得到以下输出

python selftest.py
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY 
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
*** LITTLECMS support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.

但是当我从浏览器访问我的应用程序时,我仍然得到解码器 jpeg 不可用

注意:我重新启动了 apache 服务器(不确定是否需要)。 我需要在 Apache 中进行一些配置更改吗?

我在*上搜索,发现了类似的问题,但没有一个是在处理apache。

【问题讨论】:

    标签: django apache python-2.7 python-imaging-library


    【解决方案1】:

    我也遇到了同样的错误。原因是在服务器上运行的其他站点。它在 python 路径中有旧的 PIL。因此,清理 python 路径或重新安装旧 PIL 可能会对您有所帮助。

    【讨论】: