Skip to main content
 首页 » 编程设计

python之安装 Pillow Raspbian Python 3.5 时遇到问题(缺少 JPEG 依赖项)

2025年02月15日11wuhuacong

正如您在标题中所读到的,我在 Raspbian Jessie (raspberry pi 3) 上安装 Pillow for Python 3 时遇到问题。错误说:

The headers or library files could not be found for jpeg, 
a required dependency when compiling Pillow from source. 

加上整整 300 行其他内容,如果 pastebin 有帮助,http://pastebin.com/b3UUskB4

我已尝试确保所有必需的依赖项,http://pillow.readthedocs.io/en/3.0.x/installation.html#old-versions , 安装如下:

apt-cache search <dependency name> 
sudo apt-get install <name found from previous command> 

特别是对于 libjpeg 和 openjpeg(我认为是问题所在的 2 个),我做了:

sudo apt-get install libjpeg8 
sudo apt-get install libopenjpeg5 

我来这里之前也搜索过这个问题。我找到了一个线程,https://askubuntu.com/questions/156484/how-do-i-install-python-imaging-library-pil ,它用于 pil 而不是 pillow,表示 pillow 可能在错误的位置寻找这些依赖项,在这种情况下我应该执行以下操作:

sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /lib/ 
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so.6 /usr/lib/ 
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so.62 /usr/lib/ 

但由于这些确切的命令不适用于我的特定情况,我尝试修复它们并改为:

sudo ln -s /usr/lib/arm-linux-gnueabihf/libjpeg.so.62 /usr/lib 

所以我真的不确定我在这里做错了什么,但是非常感谢任何指导,在此先感谢您的帮助!

请您参考如下方法:

我要在这里建议,由于 Jessie 是 Debian,而 Ubuntu 是 Debian 的一种风格,我们可以查看一些 Ubuntu 帖子以寻求帮助。我有一些在微型计算机上使用 Python 和 Debian 的经验,事实上我发现 apt-get 业务与桌面上的 Ubuntu 非常相似。

也就是说,this post可能会提供解决方案 --- 尝试使用 build-dep 而不是 install。特别是,请参阅 roadmr 在 2013 年 7 月 26 日的回答以及他提供的链接。