IOError:使用枕头时,解码器jpeg不可用 [英] IOError: decoder jpeg not available when using Pillow

查看:67
本文介绍了IOError:使用枕头时,解码器jpeg不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在有人说"sudo apt-get install libjpeg-dev"或类似的内容之前,我没有sudo访问权限.我在不允许我具有sudo访问权限的服务器上.因此,我必须在本地目录中完成整个操作.那是我唯一的方法.

Before someone says "sudo apt-get install libjpeg-dev" or something along those lines, I do not have sudo access. I am on a slice of a server that does NOT allow me to have sudo access. So I've gotta do this entire thing in my local directory. That's the only way I can do it.

我需要一个python脚本来调整图像大小.对于png文件,它可以很好地工作,但是对于jpeg文件,它却会崩溃,标题中列出了错误.

I need a python script to resize an image. It works perfectly fine for png files, but it falls apart on jpeg files with the error listed in the title.

这是我到目前为止采取的步骤:

Here are the steps I've taken so far:

  1. 下载了libjpeg-dev并将其安装到$HOME/jpegtest,因此jpegtest/文件夹中的是lib/,include/等,
  2. 我手动下载了Pillow并将其提取到$HOME/Pillow
  3. 我编辑了setup.py fild,以便将JPEG_ROOT更改为libinclude(<absolute path to jpegtest>)
  4. 我构建并编译了Pillow,将其安装到$HOME//.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/Pillow-2.4.0-py2.7-linux-x86_64.egg,输出的重要部分如下:

  1. Downloaded libjpeg-dev and installed it to $HOME/jpegtest, so inside the jpegtest/ folder is lib/, include/, and so on
  2. I downloaded Pillow manually and extracted it out to $HOME/Pillow
  3. I edited the setup.py fild so the JPEG_ROOT to a libinclude(<absolute path to jpegtest>)
  4. I built and compiled Pillow, where it installed to $HOME//.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/Pillow-2.4.0-py2.7-linux-x86_64.egg The important part of the output is as follows:

*** TKINTER support not available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
*** FREETYPE2 support not available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available

所以我认为这意味着JPEG支持将起作用,但是当我运行程序时它说:

So I would assume that this means JPEG support will function, but when I run my program it says:

IOError:解码器jpeg不可用

IOError: decoder jpeg not available

在键入此内容时,我还在>枕头识别中注意到了这个问题JPEG编码器已安装,但未使用,听起来很像我的,所以我在那儿尝试了解决方案:

While typing this I also noticed the question at Pillow recognizes JPEG encoder on install, but not use, which sounded very close to mine, so I tried the solution there:

ln -s /media/sdl1/home/midnight/jpegtest/lib/libjpeg.so /media/sdl1/home/midnight/.pythonbrew/pythons/Python-2.7.5/lib

但是我仍然有同样的错误.

But I still have the same error.

我已经解决这个问题大约两天了,但我不确定要怎么做.如果有人可以提供帮助,那将非常有帮助.

I've been working on this problem for about two days now, and I'm not entirely sure what to do. If anyone could offer some assistance, that would be very helpful.

推荐答案

不只是下载所需的库,而是尝试在主文件夹本地创建一个完整的Python环境:

Instead of just downloading the libraries you need, try creating an entire Python environment in locally in your home folder:

$ wget http://www.python.org/ftp/python/[desired version of Python].tgz
$ tar xzf Python[version].tgz
$ cd python-[version]
$ ./configure
$ make altinstall prefix=~ exec-prefix=~

更新您的PATH变量,以便首先执行本地Python:

Update your PATH variable so that your local Python is executed first:

$ PATH = /home/user/[pathtopython]:$PATH

获取pip,可以从中安装其他软件包:

Obtain pip, from which other packages can be installed:

$ curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
$ ./get-pip.py
$ pip install pillow

URL可能会有所不同.您可能仍然需要修改setup.py-我尚未在类似C的库中使用此技术,所以不确定.

URLs may vary. You might still have to modify setup.py - I haven't used this technique with C-like libraries so I'm not sure.

这篇关于IOError:使用枕头时,解码器jpeg不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆