Skip to content

OSError: -9 at img.show() with a .CR2 image #5317

@SnorrenEnzo

Description

@SnorrenEnzo

Hi everyone,

Today I wanted to run a script I regularly use for image sorting, however I got an OSError: -9 occurring at the img.show(). A simplified script which can replicate this behaviour is provided at the end of this post. The image I was trying to show is a .CR2, a Canon RAW image. I have used this script extensively for more than a year on .CR2 files and it behaved flawlessly all the time, until now. It occurs with every .CR2 image, even ones that I know I have opened with Pillow before.

The full error log:

 Traceback (most recent call last):
  File "/home/user/Downloads/Pillow_bug/pillow_bug.py", line 8, in <module>
    img.show()
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/Image.py", line 2218, in show
    _show(self, title=title, command=command)
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/Image.py", line 3182, in _show
    _showxv(image, **options)
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/Image.py", line 3196, in _showxv
    ImageShow.show(image, title, **options)
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/ImageShow.py", line 56, in show
    if viewer.show(image, title=title, **options):
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/ImageShow.py", line 81, in show
    return self.show_image(image, **options)
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/ImageShow.py", line 107, in show_image
    return self.show_file(self.save_image(image), **options)
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/ImageShow.py", line 103, in save_image
    return image._dump(format=self.get_format(image), **self.options)
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/Image.py", line 636, in _dump
    self.load()
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/TiffImagePlugin.py", line 1088, in load
    return self._load_libtiff()
  File "/home/user/anaconda3/envs/picturepicker/lib/python3.9/site-packages/PIL/TiffImagePlugin.py", line 1192, in _load_libtiff
    raise OSError(err)
OSError: -9

Installed modules (made a fresh conda env for this report):

# packages in environment at /home/user/anaconda3/envs/envname:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
ca-certificates           2020.12.5            ha878542_0    conda-forge
certifi                   2020.12.5        py39hf3d152e_1    conda-forge
cycler                    0.10.0                     py_2    conda-forge
dbus                      1.13.6               hfdff14a_1    conda-forge
expat                     2.2.10               h9c3ff4c_0    conda-forge
fontconfig                2.13.1            hba837de_1004    conda-forge
freetype                  2.10.4               h0708190_1    conda-forge
gettext                   0.19.8.1          h0b5b191_1005    conda-forge
glib                      2.66.7               h9c3ff4c_1    conda-forge
glib-tools                2.66.7               h9c3ff4c_1    conda-forge
gst-plugins-base          1.18.3               h04508c2_0    conda-forge
gstreamer                 1.18.3               h3560a44_0    conda-forge
icu                       68.1                 h58526e2_0    conda-forge
jpeg                      9d                   h36c2ea0_0    conda-forge
kiwisolver                1.3.1            py39h1a9c180_1    conda-forge
krb5                      1.17.2               h926e7f8_0    conda-forge
lcms2                     2.12                 hddcbb42_0    conda-forge
ld_impl_linux-64          2.35.1               hea4e1c9_2    conda-forge
libblas                   3.9.0                8_openblas    conda-forge
libcblas                  3.9.0                8_openblas    conda-forge
libclang                  11.1.0          default_ha53f305_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libevent                  2.1.10               hcdb4288_3    conda-forge
libffi                    3.3                  h58526e2_2    conda-forge
libgcc-ng                 9.3.0               h2828fa1_18    conda-forge
libgfortran-ng            9.3.0               hff62375_18    conda-forge
libgfortran5              9.3.0               hff62375_18    conda-forge
libglib                   2.66.7               h3e27bee_1    conda-forge
libgomp                   9.3.0               h2828fa1_18    conda-forge
libiconv                  1.16                 h516909a_0    conda-forge
liblapack                 3.9.0                8_openblas    conda-forge
libllvm11                 11.1.0               hf817b99_0    conda-forge
libopenblas               0.3.12          pthreads_h4812303_1    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libpq                     13.1                 hfd2b0eb_2    conda-forge
libstdcxx-ng              9.3.0               h6de172a_18    conda-forge
libtiff                   4.2.0                hdc55705_0    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libwebp-base              1.2.0                h7f98852_0    conda-forge
libxcb                    1.13              h7f98852_1003    conda-forge
libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
libxml2                   2.9.10               h72842e0_3    conda-forge
lz4-c                     1.9.3                h9c3ff4c_0    conda-forge
matplotlib                3.3.4            py39hf3d152e_0    conda-forge
matplotlib-base           3.3.4            py39h2fa2bec_0    conda-forge
mysql-common              8.0.23               ha770c72_1    conda-forge
mysql-libs                8.0.23               h935591d_1    conda-forge
ncurses                   6.2                  h58526e2_4    conda-forge
nspr                      4.29                 h9c3ff4c_1    conda-forge
nss                       3.62                 hb5efdd6_0    conda-forge
numpy                     1.20.1           py39hdbf815f_0    conda-forge
olefile                   0.46               pyh9f0ad1d_1    conda-forge
openssl                   1.1.1j               h7f98852_0    conda-forge
pcre                      8.44                 he1b5a44_0    conda-forge
pillow                    8.1.1            py39hf95b381_0    conda-forge
pip                       21.0.1             pyhd8ed1ab_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.12.3           py39hf3d152e_7    conda-forge
pyqt-impl                 5.12.3           py39h0fcd23e_7    conda-forge
pyqt5-sip                 4.19.18          py39he80948d_7    conda-forge
pyqtchart                 5.12             py39h0fcd23e_7    conda-forge
pyqtwebengine             5.12.1           py39h0fcd23e_7    conda-forge
python                    3.9.2           hffdb5ce_0_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.9                      1_cp39    conda-forge
qt                        5.12.9               hda022c4_4    conda-forge
readline                  8.0                  he28a2e2_2    conda-forge
setuptools                49.6.0           py39hf3d152e_3    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.34.0               h74cdb3f_0    conda-forge
tk                        8.6.10               h21135ba_1    conda-forge
tornado                   6.1              py39h3811e60_1    conda-forge
tzdata                    2021a                he74cb21_0    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h516909a_1010    conda-forge
zstd                      1.4.9                ha95c52a_0    conda-forge`

What did you do?

Run the script below.

What did you expect to happen?

To show the image.

What actually happened?

An error occurred and no image was shown.

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 20.10
  • Python: 3.9.2
  • Pillow: 8.1.1

Code:

from PIL import Image

#Canon RAW image format
img = Image.open('img.CR2')

#output: <PIL.TiffImagePlugin.TiffImageFile image mode=RGB size=1936x1288 at 0x7F98F32D8C10>
print(img)

img.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnacondaIssues with Anaconda's PillowTIFF

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions