Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip error: "The headers or library files could not be found for jpeg" #5042

Closed
setanarut opened this issue Nov 15, 2020 · 37 comments
Closed
Labels
Installation Usually a problem with … macOS

Comments

@setanarut
Copy link

What did you do?

pip3 install Pillow

What did you expect to happen?

installing the package properly without the hassle.

What actually happened?

 Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/72/hplzps2136jc7fy5jf8k4hs00000gn/T/pip-install-o9zi3d_u/pillow/setup.py", line 914, in <module>
      raise RequiredDependencyException(msg)
  __main__.RequiredDependencyException:
  
  The headers or library files could not be found for jpeg,
  a required dependency when compiling Pillow from source.
  
  Please see the install instructions at:
     https://pillow.readthedocs.io/en/latest/installation.html
  ----------------------------------------
  ERROR: Failed building wheel for Pillow

What are your OS, Python and Pillow versions?

  • OS: macOS Big Sur 11.0.1
  • Python: Python 3.9.0 (default, Nov 14 2020, 10:50:03) [Clang 12.0.0 (clang-1200.0.32.27)] on darwin
  • Pillow: 8.0.1

I was able to install after a short search engine research

  1. brew install libjpeg
  2. pip3 install Pillow
@radarhere radarhere added Installation Usually a problem with … macOS labels Nov 15, 2020
@nulano
Copy link
Contributor

nulano commented Nov 15, 2020

These libraries are listed in the macOS installation from source instructions linked in the error message: https://pillow.readthedocs.io/en/stable/installation.html#building-on-macos

However, this shouldn't be necessary, since Pillow does provide pre-built wheels for macOS: https://pypi.org/project/Pillow/#files (Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl sounds like the right file)

Are you using one of the new Apple Silicon Macs?

@setanarut
Copy link
Author

setanarut commented Nov 16, 2020

No, macbook pro 2016 intel i7

@setanarut
Copy link
Author

setanarut commented Nov 16, 2020

It's a packaging issue, I'm not sure if the PIP or Pillow is to blame. both are responsible.

@hugovk
Copy link
Member

hugovk commented Nov 16, 2020

What version of pip do you have? Does it help to upgrade it?

We also recommend running python3 -m pip install ... (or whatever your python command is) instead of pip install ... to make it explicit which Python you're installing for.

If it doesn't help, please can you post the full verbose output of python3 -m pip install Pillow -v

@setanarut
Copy link
Author

setanarut commented Nov 16, 2020

@hugovk- Big sur clean installation, everything is the latest version. Latest python3 installed with brew.

  1. brew install python3
  2. brew link python3
  3. pip3 install Pillow
    Using pip 20.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

@hugovk
Copy link
Member

hugovk commented Nov 16, 2020

Thanks, what do you get when running this?

python3 -m pip install Pillow -v

@setanarut
Copy link
Author

setanarut commented Nov 16, 2020

Thanks, what do you get when running this?

python3 -m pip install Pillow -v
  1. brew uninstall libjpeg
  2. pip3 uninstall Pillow
  3. python3 -m pip install Pillow -v

I got 683 KB, 1986 lines output. I don't want to paste it here.

Last two lines;

.....
Successfully installed Pillow-8.0.1
Removed build tracker: '/private/var/folders/72/hplzps2136jc7fy5jf8k4hs00000gn/T/pip-req-tracker-ga908n34'

@hugovk
Copy link
Member

hugovk commented Nov 16, 2020

If you don't want to paste it here, please could you upload it as a zip file or to https://gist.github.com/ or pastebin?

The reason I ask is because it might help us find out why it's not installing a prebuilt binary wheel and is attempting to build from source.

There should be stuff like this, showing in my case that it found Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl as a potential match, and skipped those for Linux and other Python versions:

...
  Skipping link: none of the wheel's tags match: cp38-cp38-manylinux2014_aarch64: https://files.pythonhosted.org/packages/c0/77/ca05a9365fc72252522c1b6a6cc1f579cb5791e824480c6499b789f5a988/Pillow-8.0.1-cp38-cp38-manylinux2014_aarch64.whl#sha256=7c9401e68730d6c4245b8e361d3d13e1035cbc94db86b49dc7da8bec235d0015 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
  Skipping link: none of the wheel's tags match: cp38-cp38-win32: https://files.pythonhosted.org/packages/f4/8c/45f28efc015ec0040bb6cbde9e763140818388938dd0d2f9e6304322f11f/Pillow-8.0.1-cp38-cp38-win32.whl#sha256=6c1aca8231625115104a06e4389fcd9ec88f0c9befbabd80dc206c35561be271 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
  Skipping link: none of the wheel's tags match: cp38-cp38-win_amd64: https://files.pythonhosted.org/packages/d2/2c/9ac71068585b3d528349be6617ed963068bfcba3da21018cdb0d2b19f07c/Pillow-8.0.1-cp38-cp38-win_amd64.whl#sha256=cc9ec588c6ef3a1325fa032ec14d97b7309db493782ea8c304666fb10c3bd9a7 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
  Found link https://files.pythonhosted.org/packages/b2/a2/5a1924e8af7e197c277127be7682a2491d7c1a144b008dd40830f6567bfb/Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl#sha256=eb472586374dc66b31e36e14720747595c2b265ae962987261f044e5cce644b5 (from https://pypi.org/simple/pillow/) (requires-python:>=3.6), version: 8.0.1
  Skipping link: none of the wheel's tags match: cp39-cp39-manylinux1_i686: https://files.pythonhosted.org/packages/c5/a1/c922dedd3c075431395a1672413f891a5921988a7bab2c1088ff57a5897f/Pillow-8.0.1-cp39-cp39-manylinux1_i686.whl#sha256=0eeeae397e5a79dc088d8297a4c2c6f901f8fb30db47795113a4a605d0f1e5ce (from https://pypi.org/simple/pillow/) (requires-python:>=3.6)
...

But wait!

Successfully installed Pillow-8.0.1

Looks like it's working now?

@setanarut
Copy link
Author

PIP installs package but Image module fails without libjpeg

....   
 from PIL import Image
  File "/usr/local/lib/python3.9/site-packages/PIL/Image.py", line 94, in <module>
    from . import _imaging as core
ImportError: dlopen(/usr/local/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so, 2): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.9.dylib
  Referenced from: /usr/local/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so
  Reason: image not found

@setanarut

This comment has been minimized.

@hugovk
Copy link
Member

hugovk commented Nov 16, 2020

Starting with Pillow 3.0.0, libjpeg is required by default, but may be disabled with the --disable-jpeg flag.

https://pillow.readthedocs.io/en/stable/installation.html#building-from-source

@setanarut
Copy link
Author

Starting with Pillow 3.0.0, libjpeg is required by default, but may be disabled with the --disable-jpeg flag.

https://pillow.readthedocs.io/en/stable/installation.html#building-from-source

libjpeg is not the default in the operating system, but the default for Pillow. I hate ad hominem developers.

@wiredfool
Copy link
Member

Please don’t be rude to the developers trying to help you on a platform released within the last week.

@setanarut

This comment has been minimized.

@setanarut setanarut reopened this Nov 16, 2020
@radarhere
Copy link
Member

Having just upgraded to Big Sur and trying to install Pillow into Python 3.6 using pip, I also see that the binary wheels are not being recognised.

Looking around, this seems to be a wider problem than just Pillow.

pypa/pip#9138 (comment)

The cause is clear, pip is not seeing a wheel built for MacOS 10.x as valid for MacOS 11.

pypa/packaging#319 is a potential solution.

@v-a-zagoruyko
Copy link

Refer to this comments:
#4816 (comment)
pytorch/pytorch#47978 (comment)

@radarhere
Copy link
Member

pypa/packaging#319 has now been merged. Testing again, I find that pip now installs using the binary.

@hazarek if you are interested in trying again, I think you might also find that the binary wheel is detected, meaning that it should now successfully install on your machine?

@setanarut
Copy link
Author

i will try tonight

@setanarut
Copy link
Author

@radarhere

➜  ~ pip3 install Pillow
Collecting Pillow
  Using cached Pillow-8.0.1-cp39-cp39-macosx_10_10_x86_64.whl (2.2 MB)
Installing collected packages: Pillow
Successfully installed Pillow-8.0.1

@bschollnick
Copy link

Doesn't appear to be detected on the M1 Silicone Macs...?

(downloader) benjamin@Nerv shellscripts % pip install pillow
Collecting pillow
  Using cached https://files.pythonhosted.org/packages/2b/06/93bf1626ef36815010e971a5ce90f49919d84ab5d2fa310329f843a74bc1/Pillow-8.0.1.tar.gz
Installing collected packages: pillow
  Running setup.py install for pillow ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/benjamin/venvs/downloader/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/setup.py'"'"'; __file__='"'"'/private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-record-oat96_vk/install-record.txt --single-version-externally-managed --compile --install-headers /Users/benjamin/venvs/downloader/include/site/python3.8/pillow
         cwd: /private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/
    Complete output (174 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14.6-arm64-3.8
    creating build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/MpoImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageMode.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PngImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/XbmImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PcxImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/SunImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/SpiderImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/TarIO.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/FitsStubImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/MpegImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/BdfFontFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/GribStubImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageStat.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PixarImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/GimpPaletteFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageColor.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ContainerIO.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/MspImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/MicImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/_version.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImtImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/GifImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PalmImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageQt.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageMath.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PaletteFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/FontFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PdfParser.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ExifTags.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageCms.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/FpxImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageChops.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/BufrStubImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PSDraw.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PcdImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageFilter.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageDraw2.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImagePath.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/DcxImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/__init__.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/JpegPresets.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/features.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageDraw.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/GimpGradientFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageWin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/IcoImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/_tkinter_finder.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/EpsImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/TgaImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageMorph.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/WalImageFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PcfFontFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/BlpImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageTk.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/GbrImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageOps.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PdfImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageShow.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageEnhance.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/WmfImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageGrab.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/WebPImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/FliImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/TiffTags.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/CurImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/_util.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/GdImageFile.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/TiffImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/IptcImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImagePalette.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/BmpImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageTransform.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/IcnsImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/McIdasImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/XpmImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/DdsImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageSequence.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PyAccess.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/_binary.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/Image.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/__main__.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/XVThumbImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/SgiImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PsdImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/JpegImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/ImageFont.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/PpmImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    copying src/PIL/FtexImagePlugin.py -> build/lib.macosx-10.14.6-arm64-3.8/PIL
    running egg_info
    writing src/Pillow.egg-info/PKG-INFO
    writing dependency_links to src/Pillow.egg-info/dependency_links.txt
    writing top-level names to src/Pillow.egg-info/top_level.txt
    reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.c'
    warning: no files found matching '*.h'
    warning: no files found matching '*.sh'
    warning: no previously-included files found matching '.appveyor.yml'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.readthedocs.yml'
    warning: no previously-included files found matching 'codecov.yml'
    warning: no previously-included files matching '.git*' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    no previously-included directories found matching '.ci'
    writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
    running build_ext
    
    
    The headers or library files could not be found for jpeg,
    a required dependency when compiling Pillow from source.
    
    Please see the install instructions at:
       https://pillow.readthedocs.io/en/latest/installation.html
    
    Traceback (most recent call last):
      File "/private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/setup.py", line 861, in <module>
        setup(
      File "/Users/benjamin/venvs/downloader/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Users/benjamin/venvs/downloader/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/install.py", line 561, in run
        self.run_command('build')
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Users/benjamin/venvs/downloader/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 84, in run
        _build_ext.run(self)
      File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build_ext.py", line 340, in run
        self.build_extensions()
      File "/private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/setup.py", line 698, in build_extensions
        raise RequiredDependencyException(f)
    __main__.RequiredDependencyException: jpeg
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/setup.py", line 914, in <module>
        raise RequiredDependencyException(msg)
    __main__.RequiredDependencyException:
    
    The headers or library files could not be found for jpeg,
    a required dependency when compiling Pillow from source.
    
    Please see the install instructions at:
       https://pillow.readthedocs.io/en/latest/installation.html
    
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/benjamin/venvs/downloader/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/setup.py'"'"'; __file__='"'"'/private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-install-jycwtrjx/pillow/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6g/0vldjqgd5d55rdv163phqh6r0000gn/T/pip-record-oat96_vk/install-record.txt --single-version-externally-managed --compile --install-headers /Users/benjamin/venvs/downloader/include/site/python3.8/pillow Check the logs for full command output.

@eashishkalra
Copy link

Any solution for error above for M1 Mac installation?

@aclark4life
Copy link
Member

@bschollnick You probably don't want to compile, you probably want there to be a wheel… @eashishkalra Traceback?

@python-pillow/pillow-team Maybe we just need to leave one of these "headers or library files" issues opened permanently … and then paste in links to other more relevant issues … e.g. "wheels for M1 macs" ?

@setanarut
Copy link
Author

@eashishkalra

  1. brew install libjpeg
  2. pip3 install Pillow

@nulano
Copy link
Contributor

nulano commented Dec 16, 2020

python-pillow/pillow-team Maybe we just need to leave one of these "headers or library files" issues opened permanently … and then paste in links to other more relevant issues … e.g. "wheels for M1 macs" ?

I think that was one of the inspirations for the new Discussions feature, as in most cases installation is not really an "issue" in Pillow (although it is in some cases).

@hugovk
Copy link
Member

hugovk commented Dec 16, 2020

#5093 is for the new M1 Macs, please can you try the suggestions at #5093 (comment)?

@hugovk
Copy link
Member

hugovk commented Dec 16, 2020

@python-pillow/pillow-team Maybe we just need to leave one of these "headers or library files" issues opened permanently … and then paste in links to other more relevant issues … e.g. "wheels for M1 macs" ?

We could try that, and maybe lock and pin it, but I think people often find other issues via search. The M1 issue is currently 3rd in the issue list, so not that hard to find if browsing, not searching. I'll pin that too. And we probably will need some M1 changes for the next release.

@bschollnick

This comment has been minimized.

@Bobronium
Copy link

Bobronium commented Feb 15, 2021

I have the same issue: Python 3.9, Big Sur, Intel.

python3 -m pip install Pillow -v

@hugovk, here's output.txt

After running

brew install libjpeg
brew install freetype
pip uninstall Pillow
pip install Pillow

it got installed, however, produced an error:

Traceback (most recent call last):
  File "/Users/rocky/dev/py/jpoetry/jpoetry/image.py", line 11, in <module>
    font = ImageFont.truetype("hanZi.ttf", 50)
  File "/Users/rocky/.local/share/virtualenvs/name-hash//lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in truetype
    return freetype(font)
  File "/Users/rocky/.local/share/virtualenvs/name-hash//lib/python3.9/site-packages/PIL/ImageFont.py", line 849, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/Users/rocky/.local/share/virtualenvs/name-hash//lib/python3.9/site-packages/PIL/ImageFont.py", line 185, in __init__
    if core.HAVE_RAQM:
  File "/Users/rocky/.local/share/virtualenvs/name-hash//lib/python3.9/site-packages/PIL/ImageFont.py", line 44, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

If I switch back to Python 3.8 it installs and works flawlessly. Any suggestions how to fix it on 3.9?

Solution

turns out I had old pip version in my venv, updating it solved the issue.

@hongquanvn1998
Copy link

@eashishkalra

  1. brew install libjpeg
  2. pip3 install Pillow

nice. It's work for my Mac M1

@baijifeilong
Copy link

apt install libjpeg for ubuntu

@philippefutureboy
Copy link

philippefutureboy commented Apr 7, 2021

Brand new Macbook off the shelf:

MacOS Big Sur 11.2.3
MacBook Pro (16-inch, 2019)
2.4 GHz 8-Core Intel Core i9

python -m pip install --upgrade pip in venv solves the issue for me.

Thanks to everyone who participated in this thread ❤️

@thewolfcommander
Copy link

@eashishkalra

  1. brew install libjpeg
  2. pip3 install Pillow

That works for me too... MacBook air M1 2020. Give it a try. Trust me

@chrisdlangton
Copy link

on alpine I had to run apk update && apk upgrade && apk add --no-cache freetype-dev libpng-dev jpeg-dev libjpeg-turbo-dev

@ggilperez
Copy link

Brand new Macbook off the shelf:

MacOS Big Sur 11.2.3 MacBook Pro (16-inch, 2019) 2.4 GHz 8-Core Intel Core i9

python -m pip install --upgrade pip in venv solves the issue for me.

Thanks to everyone who participated in this thread ❤️

This works for me, MacBook Air M1 2020, thanks.

@dinkopehar
Copy link

On MacOS Montery, installing jpeg-turbo solved a problem for Pillow==8.0.0.

@Didou09
Copy link

Didou09 commented Oct 17, 2022

Fails for me during my Github Action workflow to build the wheel of my library:

https://github.com/ToFuProject/tofu/actions/runs/3265080608/jobs/5366784038


      writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
      running build_ext
  
  
      The headers or library files could not be found for jpeg,
      a required dependency when compiling Pillow from source.
  
      Please see the install instructions at:
         https://pillow.readthedocs.io/en/latest/installation.html
  
      Traceback (most recent call last):
        File "/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py", line 1024, in <module>
          zip_safe=not (debug_build() or PLATFORM_MINGW),
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
          return distutils.core.setup(**attrs)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 955, in run_commands
          self.run_command(cmd)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 974, in run_command
          cmd_obj.run()
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/setuptools/command/install.py", line 68, in run
          return orig.install.run(self)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/command/install.py", line 545, in run
          self.run_command('build')
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 974, in run_command
          cmd_obj.run()
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/dist.py", line 974, in run_command
          cmd_obj.run()
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
          _build_ext.run(self)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
          _build_ext.build_ext.run(self)
        File "/opt/_internal/cpython-3.6.15/lib/python3.6/distutils/command/build_ext.py", line 339, in run
          self.build_extensions()
        File "/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py", line 790, in build_extensions
          raise RequiredDependencyException(f)
      __main__.RequiredDependencyException: jpeg
  
      During handling of the above exception, another exception occurred:
  
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py", line 1037, in <module>
          raise RequiredDependencyException(msg)
      __main__.RequiredDependencyException:
  
      The headers or library files could not be found for jpeg,
      a required dependency when compiling Pillow from source.
  
      Please see the install instructions at:
         https://pillow.readthedocs.io/en/latest/installation.html
  
  
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /opt/_internal/cpython-3.6.15/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py'"'"'; __file__='"'"'/tmp/pip-install-upaphstl/pillow_137a411b2c1640fc9ddca2e4fb5e49f0/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vdxsr3c1/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-gcizpx28/overlay --compile --install-headers /tmp/pip-build-env-gcizpx28/overlay/include/python3.6m/pillow Check the logs for full command output.

  ----------------------------------------
WARNING: Discarding file:///github/workspace. Command errored out with exit status 1: /opt/_internal/cpython-3.6.15/bin/python /opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-gcizpx28/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel 'cython>0.26' numpy Polygon3 'datastock>=0.0.20' Check the logs for full command output.
ERROR: Command errored out with exit status 1: /opt/_internal/cpython-3.6.15/bin/python /opt/_internal/cpython-3.6.15/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-gcizpx28/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel 'cython>0.26' numpy Polygon3 'datastock>=0.0.20' Check the logs for full command output.
+ echo 'Building wheels failed.'
+ exit 1
Building wheels failed.
0s
0s
0s

@nulano , any idea how to fix it for github Actions ? This is preventing me from releasing a new version...

@hugovk
Copy link
Member

hugovk commented Oct 17, 2022

@Didou09 If building from source, make sure you have the non-Python dependencies installed. See https://pillow.readthedocs.io/en/stable/installation.html#building-from-source

If that doesn't help, please create a new issue. (And we no longer support Python 3.6, it's EOL since last year.)

@python-pillow python-pillow locked as resolved and limited conversation to collaborators Oct 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Installation Usually a problem with … macOS
Projects
None yet
Development

No branches or pull requests