如何在树莓派上安装具有JPEG支持的PIL

如何在树莓派上安装具有JPEG支持的PIL

本文介绍了如何在树莓派上安装具有JPEG支持的PIL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在树莓派上安装 PIL 并读取JPEG文件.但是,它开箱即用.

I tried to install PIL on my raspberry pi and read JPEG files. However, it does not work out of the box.

当我运行以下命令时:

sudo pip install pil

我收到以下错误,尝试打开图像:

I receive the following error, trying to open an Image:

""decoder jpeg not available""

在尝试安装所有必需的JPEG库时,我遇到了一些错误,例如:

While trying to install all needed JPEG libraries I ran into some errors e.g.:

sudo apt-get install libjpeg
E: Unable to locate package libjpeg

推荐答案

您必须重新安装PIL,还必须安装所需的库并手动链接它们.该答案基于此博客文章(用于常规ubuntu PIL安装)和 askubuntu问题,其中说明了如何编译jpeg编码:

You have to re-install PIL and also install the needed libraries as well as link them manually. This answer is based on this blog post for a regular ubuntu PIL installation and this askubuntu question, where it is explained how to compile the jpeg encoding:

### uninstall PIL
sudo pip uninstall pil

### download and compile the JPEG library
wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
tar xvfz jpegsrc.v8c.tar.gz
cd jpeg-8c
./configure --enable-shared --prefix=$CONFIGURE_PREFIX
make
sudo make install

### link the libraries correctly - RASPBERRY PI ONLY
sudo ln -s /usr/lib/arm-linux-gnueabi/libjpeg.so /usr/lib
sudo ln -s /usr/lib/arm-linux-gnueabi/libfreetype.so /usr/lib
sudo ln -s /usr/lib/arm-linux-gnueabi/libz.so /usr/lib

### install rest of the libraries, as well as freetrype and zlib
sudo apt-get install libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

### re-install PIL
sudo pip install pil

希望能帮助到某人!

这篇关于如何在树莓派上安装具有JPEG支持的PIL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:42