2

As you read in the title, I'm having trouble installing Pillow for Python 3 on Raspbian Jessie (raspberry pi 3). The error says:

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

plus a whole 300 some lines of other stuff, if the pastebin helps, http://pastebin.com/b3UUskB4

I've tried making sure all required dependencies, http://pillow.readthedocs.io/en/3.0.x/installation.html#old-versions , were installed as follows:

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

And specifically for libjpeg and openjpeg (the 2 that I'd assume are the problem), I did:

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

I've also searched this issue before coming here. One thread I found, https://askubuntu.com/questions/156484/how-do-i-install-python-imaging-library-pil , which is for pil rather than pillow, said that pillow is probably looking in the wrong place for those dependencies, in which case I should execute the following:

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/

but since those exact commands aren't going to work for my specific case, I tried to fix them and instead did:

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

So really I'm not sure what I'm doing wrong here, but any guidance would be greatly appreciated, thanks in advance for any help!

Community
  • 1
  • 1
jcavejr
  • 131
  • 1
  • 8

1 Answers1

3

I'm going to suggest here that since Jessie is Debian and Ubuntu is a flavor of Debian that we can take a look at some Ubuntu posts for help. I have some experience with Python and Debian on microcomputers and indeed I found the apt-get business to go much the same as with Ubuntu on the desktop.

To wit, this post may provide the solution--- try build-dep rather than install. In particular, see the answer by roadmr on Jul 26 '13 and the links that he provides.

Community
  • 1
  • 1
Mike O'Connor
  • 2,494
  • 1
  • 15
  • 17
  • I should add that I have come across the advice that you may need to invoke the [`--no-cache-dir`](https://pip.pypa.io/en/stable/reference/pip_install/#caching) option. See for example [this post](http://stackoverflow.com/questions/9510474/removing-pips-cache) for a similar need to avoid trying to make use of a prior bad install attempt. I have in mind in particular the post by dafeda of Dec 27 '14. – Mike O'Connor Feb 14 '17 at 01:23
  • apt-get build-dep matplotlib solved all for me – Sebapi Nov 28 '21 at 04:05