我尝试在我的树莓派上安装PIL并阅读JPEG文件。但是,它不能开箱即用。
当我运行以下内容时:
sudo pip install pil
我收到以下错误,尝试打开图片:
""decoder jpeg not available""
在尝试安装所有需要的JPEG库时,我遇到了一些错误,例如:
sudo apt-get install libjpeg
E: Unable to locate package libjpeg
答案 0 :(得分:16)
您必须重新安装PIL并安装所需的库并手动链接它们。对于常规的ubuntu PIL安装和this blog post,这个答案基于askubuntu question,其中解释了如何编译jpeg编码:
### 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
希望能帮助别人!