33

I have a fresh, minimal Raspbian Stretch install. I have installed the PIXEL-dekstop by running sudo apt-get install --no-install-recommends xserver-xorg and am now trying to use Pillow in Python. Pillow was installed by running sudo apt-get install pip3 and then sudo pip3 install Pillow. Whenever I try from PIL import Image I get the error ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory.

I have attempted to reinstall Pillow under different versions but it does not help. I have also enabled apt-get sources in /etc/apt/sources.txt and ran sudo apt-get build-dep python-imaging, which also did not help. Any help is appreciated.

Python version: 3.5.3, current Pillow version: 4.3.0

Simon Carlson
  • 1,919
  • 5
  • 24
  • 35
  • 7
    execute: `sudo apt-get install libopenjp2-7-dev` – eyllanesc Dec 28 '17 at 18:35
  • @eyllanesc thank you, this solved it. Do you have any tips for how I could (in general) find the right packages when I'm missing dependencies? How did you find out about `libopenjp2-7-dev`? – Simon Carlson Dec 29 '17 at 15:40
  • 1
    I just google: ubuntu libopenjp2.so.7 since many of the raspbian packages are the same as ubuntu, and then enter the first link: https://packages.ubuntu.com/search?keywords=libopenjp2-7, Then remember that the -dev packages are for developers and that is what they are needed. – eyllanesc Dec 29 '17 at 15:44
  • @eyllanesc Thanks a bunch! – Simon Carlson Dec 29 '17 at 15:47

1 Answers1

77

What worked for me was running :

sudo apt-get install libopenjp2-7

Good Luck!

Paulo Cirino
  • 994
  • 7
  • 9
  • 17
    YESSS! That worked for me on Raspbian. I then had a similar error regarding libtiff.so.5 and solved it with ```sudo apt-get install libtiff5``` – Steak Overflow Jun 27 '20 at 09:32
  • 1
    Thanks! I had to do this additional step too! – flying_loaf_3 Dec 16 '20 at 08:22
  • 6
    Also had to do the following for installing the [face_recognition](https://github.com/ageitgey/face_recognition) library. In summary: `sudo apt-get install libopenjp2-7 libtiff5 libatlas-base-dev` – flying_loaf_3 Dec 16 '20 at 08:30