python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.36k stars 2.24k forks source link

Unable to install Pillow on the Macbook Pro 13 M1 Silicon #5093

Closed HarshSonawane closed 3 years ago

HarshSonawane commented 3 years ago

What did you do?

I tried installing a pillow with the pipenv, I have a python version 3.9.1 installed and tried to install a pillow with that but facing this issue mentioned below.

What did you expect to happen?

I wanted to use pillow with django.

What actually happened?

Pillow installation causing error continuously, the error is mentioned below.

What are your OS, Python, and Pillow versions?

Collecting Pillow==7.2.0
  Using cached Pillow-7.2.0.tar.gz (39.1 MB)
Building wheels for collected packages: Pillow
  Building wheel for Pillow (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py'"'"'; __file__='"'"'/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-wheel-rk7rd8w9
       cwd: /private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/
  Complete output (172 lines):
  running bdist_wheel
  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'
  warning: build_py: byte-compiling is disabled, skipping.

  running build_ext

  The headers or library files could not be found for zlib,
  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/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py", line 864, in <module>
      setup(
    File "/Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/Library/Developer/CommandLineTools/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/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py", line 694, in build_extensions
      raise RequiredDependencyException(f)
  __main__.RequiredDependencyException: zlib

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py", line 918, in <module>
      raise RequiredDependencyException(msg)
  __main__.RequiredDependencyException:

  The headers or library files could not be found for zlib,
  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
  Running setup.py clean for Pillow
Failed to build Pillow
Installing collected packages: Pillow
    Running setup.py install for Pillow ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py'"'"'; __file__='"'"'/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/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/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-record-sbw6wf02/install-record.txt --single-version-externally-managed --compile --install-headers /Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/include/site/python3.8/Pillow
         cwd: /private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/
    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'
    warning: build_py: byte-compiling is disabled, skipping.

    running build_ext

    The headers or library files could not be found for zlib,
    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/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py", line 864, in <module>
        setup(
      File "/Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/install.py", line 561, in run
        self.run_command('build')
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Library/Developer/CommandLineTools/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/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py", line 694, in build_extensions
        raise RequiredDependencyException(f)
    __main__.RequiredDependencyException: zlib

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py", line 918, in <module>
        raise RequiredDependencyException(msg)
    __main__.RequiredDependencyException:

    The headers or library files could not be found for zlib,
    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/harsh/.local/share/virtualenvs/pdist-o77J8eHd/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/setup.py'"'"'; __file__='"'"'/private/var/folders/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-install-exv5oeqg/pillow_d26c2175614649e1b0d3d03ff481fca6/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/6z/3hxj8p2s6vlgfynhc4wvxfd00000gn/T/pip-record-sbw6wf02/install-record.txt --single-version-externally-managed --compile --install-headers /Users/harsh/.local/share/virtualenvs/pdist-o77J8eHd/include/site/python3.8/Pillow Check the logs for full command output.
hugovk commented 3 years ago

First off, any particular reason to use Pillow 7.2.0 on not 8.x? Python 3.9 support was officially added to Pillow in 8.0.0:

https://pillow.readthedocs.io/en/stable/installation.html#python-support


I think there's still some work going on in the packaging world to support Apple silicon, and so it's attempting to install and build from source.

Please could you first try after updating pip and wheel?


It's also possible to download one of the wheels from https://pypi.org/project/Pillow/8.0.1/#files and change one of the tags in the filename, and pip install that, but I can't find the details for that now. It was something like replace x86_64 with universal2.


Or to build from source, you need to install some dependencies first:

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

Please see the install instructions at:
   https://pillow.readthedocs.io/en/latest/installation.html
HarshSonawane commented 3 years ago

Thank you for reaching back. I have also tried with pillow version 8.0.1 but the same issue is going on, unable to install Pillow.

jia611 commented 3 years ago

I have same question I try execute

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

on the Macbook Pro 13 M1 Silicon have the same question on the Macbook Air Intel Core is Successfully

hugovk commented 3 years ago

@jia611 Please can you try this? (Instructions based on https://github.com/scipy/scipy/issues/13102#issuecomment-733988544)

  1. Find your tag
    
    $ python3 -m pip install packaging
    $ python3 -c"from packaging import tags; print('\n'.join([str(t) for t in tags.sys_tags()]))" |head -5

cp38-cp38-macosx_11_0_x86_64


2. Download 8.0.1 wheel from PyPI https://pypi.org/project/Pillow/8.0.1/#files
3. Rename downloaded file to match your tag
```sh
mv Pillow-8.0.1-cp38-cp38-macosx_10_10_x86_64.whl Pillow-8.0.1-cp38-cp38-macosx_11_0_x86_64.whl
  1. Install wheel
    python3 -m pip install Pillow-8.0.1-cp38-cp38-macosx_11_0_x86_64.whl

Or https://github.com/scipy/scipy/issues/13102#issuecomment-744473479:

Fwiw, I managed to install scipy on Big Sur (Intel Macbook) by using the compatibility mode, in which macOS will report being version 10.16 instead of 11.0:

export SYSTEM_VERSION_COMPAT=1
> sw_vers -productVersion
10.16
jia611 commented 3 years ago

python3 -m pip install Pillow-8.0.1-cp38-cp38-macosx_11_0_x86_64.whl is error

ERROR: Pillow-8.0.1-cp38-cp38-macosx_11_0_x86_64.whl is not a supported wheel on this platform.

hugovk commented 3 years ago

@jia611 What output do you get for this?

python3 -c"from packaging import tags; print('\n'.join([str(t) for t in tags.sys_tags()]))" |head -5
jia611 commented 3 years ago

@jia611 What output do you get for this?

python3 -c"from packaging import tags; print('\n'.join([str(t) for t in tags.sys_tags()]))" |head -5

cp38-cp38-macosx_11_0_arm64 cp38-cp38-macosx_11_0_universal2 cp38-abi3-macosx_11_0_arm64 cp38-abi3-macosx_11_0_universal2 cp38-none-macosx_11_0_arm64

hugovk commented 3 years ago

Then please try renaming it to match one of those, for example Pillow-8.0.1-cp38-cp38-macosx_11_0_universal2.whl

geoffsharris commented 3 years ago

Perhaps an obvious answer to be had. If I download and change to Pillow-8.0.1-cp38-cp38-macosx_11_0_universal2.whl where do I put the file to actually run sudo python3 -m pip install Pillow-8.0.1-cp38-cp38-macosx_11_0_universal2.whl?

radarhere commented 3 years ago

In your current directory. Or you could change the command to use a relative path. Or, you could specify an absolute path, e.g. sudo python3 -m pip install /Users/geoffsharris/Downloads/Pillow-8.0.1-cp38-cp38-macosx_11_0_universal2.whl

jia611 commented 3 years ago

Then please try renaming it to match one of those, for example Pillow-8.0.1-cp38-cp38-macosx_11_0_universal2.whl

thank you Successfully installed Pillow-8.0.1

hugovk commented 3 years ago

Good to hear, thanks for testing!


Now the question is what changes do we need to make for the next release to be pip installable on M1 from PyPI? Are changes needed at multibuild? I think pip+packaging (https://github.com/pypa/packaging/pull/319) and wheel (https://github.com/pypa/wheel/pull/390) are ready.

goleador commented 3 years ago

The installation worked on my Macbook Pro 13 M1 but when I try to use it still has problems. I am trying to run the https://github.com/tensorflow/hub/blob/master/examples/colab/object_detection.ipynb notebook.

I get the following error: dlopen(python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so, 2): no suitable image found. Did find: tensorflow_venv/lib/python3.8/site-packages/PIL/_imaging.cpython-38-darwin.so: mach-o, but wrong architecture

radarhere commented 3 years ago

@goleador how did you install Pillow?

starup commented 3 years ago

@radarhere I have the same problem as @goleador

when i run python3 in arm arch,python3 main.py ,error log is:

    from PIL import Image, ImageDraw, ImageFont, ImageFilter
  File "/Users/tx/Work/dykt_back/venv/lib/python3.9/site-packages/PIL/Image.py", line 94, in <module>
    from . import _imaging as core
ImportError: dlopen(/Users/tx/Work/dykt_back/venv/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so, 2): no suitable image found.  Did find:
    /Users/tx/Work/dykt_back/venv/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so: mach-o, but wrong architecture
    /Users/tx/Work/dykt_back/venv/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so: mach-o, but wrong architecture

and when i run arch -x86_64 python3 main.py , the service is successful.

goleador commented 3 years ago

I installed using the directions on this thread. Basically, renaming the .whl file as described above. @radarhere

radarhere commented 3 years ago

In case this is helpful to anyone, here's a wheel I put together on my M1 - Pillow-8.0.1-cp39-cp39-macosx_11_0_arm64.whl.zip

glitched-person commented 3 years ago

@radarhere Tried to install your wheel on my m1. Got : ERROR: Pillow-8.0.1-cp39-cp39-macosx_11_0_arm64.whl is not a supported wheel on this platform. . :(

radarhere commented 3 years ago

@y4nng-dev were you using Python 3.9, or a different Python version? Could you provide the full command that you used to try and install the wheel?

glitched-person commented 3 years ago

@radarhere I'm using Python 3.8.2 and here is the command I used : python3 -m pip install /Users/username/Desktop/Pillow-8.0.1-cp39-cp39-macosx_11_0_arm64.whl Thank you

radarhere commented 3 years ago

@y4nng-dev ah, yes - the wheel I attached was for Python 3.9. Here is a wheel for Python 3.8 - Pillow-8.0.1-cp38-cp38-macosx_11_0_arm64.whl.zip

glitched-person commented 3 years ago

thank you

radarhere commented 3 years ago

Now the question is what changes do we need to make for the next release to be pip installable on M1 from PyPI? Are changes needed at multibuild? I think pip+packaging (pypa/packaging#319) and wheel (pypa/wheel#390) are ready.

https://github.com/actions/virtual-environments/issues/1814 is in preview, and https://github.com/actions/runner/issues/805 is also pending. I've created https://github.com/matthew-brett/multibuild/pull/379 as a start in multibuild at least.

reach-the-sky commented 3 years ago

Create a virtual environment using venv and then try to use pip to install. It didn't work when I tried it the first time but then i used brew install libjpeg and then i tried pip then it worked.

hugovk commented 3 years ago

So in your case it must have built from source, and we don't have any matching prebuilt binary wheels.

ronaldoussoren commented 3 years ago

It would be nice to have binary wheels for the universal2 build of Python 3.9.1 on www.python.org, that would take away the need to build from source (which is finicky when you don't use homebrew)

Do note that support for universal2 wheels in the packaging space is very new, to the point that AFAIK the currently released version of pip won't install binary wheels with a platform tag that matches the above mentioned universal2 python. That should should resolve itself once my PR for the packaging library makes it way to a release of pip.

hugovk commented 3 years ago

Yes, that would be best.

https://github.com/pypa/packaging/pull/380 was merged 5 days ago, so should be vendored in the next pip 21.0, due out on 23/34 January, give or take a week (https://github.com/pypa/pip/issues/9282#issuecomment-753301504).

On the Pillow side, what do we actually need to do build universal2 binary wheels? Are changes needed in https://github.com/python-pillow/pillow-wheels or https://github.com/matthew-brett/multibuild?

ronaldoussoren commented 3 years ago

I haven't checked the two repos you mention, but there shouldn't be many changes.

I build Pillow and jpegsrc-6b from source before filing this issue and that didn't need any changes other than specifying "-arch arm64 -arch x86_64" when building the latter. That said, I haven't tested the intel part of the wheel yet (but I don't expect problems there, given past experience with the ppc to intel transition).

The main gotcha w.r.t. building universal2 wheels at the moment is that you need to build on a macOS 11 system because the sysconfig module currently assumes that compilers on older versions of the OS cannot build arm64 binaries. That's something I intent to fix and that change will hopefully be in 3.9.2.

bschollnick commented 3 years ago

Okay, obviously I'm missing something here.

(testing)  dist % pip install psycopg2-2.9.dev0-cp38-cp38-macosx_10_14_arm64.whl
ERROR: psycopg2-2.9.dev0-cp38-cp38-macosx_10_14_arm64.whl is not a supported wheel on this platform.

From a comment from Pillow:

_I build Pillow and jpegsrc-6b from source before filing this issue and that didn't need any changes other than specifying "-arch arm64 -arch x8664" when building the latter. That said, I haven't tested the intel part of the wheel yet (but I don't expect problems there, given past experience with the ppc to intel transition).

So I probably need to change the target build architecture, but I don't see where to do that... ?

ronaldoussoren commented 3 years ago

The problem you're seeing with pip is a buglet in pip (or rather packaging), PR 350 for packaging fixes that and will end up in a future release (AFAIK later this month).

There are more moving parts in the packaging space than I had expected beforehand, because of that I have spent too little time on the packaging ecosystem before the "universal2" changes ended up in a Python release.

bschollnick commented 3 years ago

Please feel free to let me know if there is anything that I can do to assist, testing, etc.

bschollnick commented 3 years ago

@radarhere

Trying to understand the build process here, how do you specify the architecture when running an package/wheel creation?

I just run a standard python setup.py sdist bdist_wheel?

I haven't found any documentation that builds a specific arch? So I'm a bit confused....

radarhere commented 3 years ago

@bschollnick I wasn't specifying the architecture - I was just building wheels on an M1 machine. It would have been python setup.py bdist_wheel and then delocate to bundle in the libraries - python delocate/cmd/delocate_wheel.py dist/Pillow-8.2.0.dev0-cp38-cp38-macosx_11_0_arm64.whl

radarhere commented 3 years ago

@bschollnick you can see over at https://github.com/python-pillow/Pillow-wheels, where we generate the Linux and macOS wheels for each release, that we're just spinning up Linux and macOS instances and building the wheel on each of them.

radarhere commented 3 years ago

@bschollnick you'll probably be interested in https://github.com/matthew-brett/multibuild/pull/383

luigi370 commented 3 years ago

Hi! So, is there any workaround to make pillow work on M1? I don't have much experience building wheels. To be honest im not even sure what is a wheel but if there is a solution to this issue I would be more than happy to know about it. Many thanks!

radarhere commented 3 years ago

Hi. I presume you have tried to install Pillow, but are getting an error like 'The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source.' Pillow is complaining that you are missing zlib, one of its dependencies.

To be clear, building wheels is not something that you do to help install a Python module on your computer, it's something that you do so that you can distribute the wheel and help other people install Pillow.

cclauss commented 3 years ago

@liuchanganshan Why use Python 3.9.1 release candidate 1 and not the Python 3.9.1 production release?

liuchanganshan commented 3 years ago

macOS 64-bit Intel installer | Mac OS X | for macOS 10.9 and later | 74f5cc5b5783ce8fb2ca55f11f3f0699 | 29795899 | SIG choose this version is ok. arm64version not ok @cclauss

cclauss commented 3 years ago

Why choose macOS 64-bit Intel installer when you are on ARM64, not Intel?

m1-macbook-pro ~ % python3

Python 3.9.1 (default, Jan  8 2021, 12:11:08)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform ; platform.processor()
'arm'

Did you try going to https://www.python.org/downloads and clicking the button Download Python 3.9.1?

Alternatively, brew install python will also install Python 3.9.1.

lixun910 commented 3 years ago

Here are some notes to compile Pillow from source with libjpeg support on M1 using arm64 architecture:

  1. compile libjpeg from source
curl -L -O http://ijg.org/files/jpegsrc.v9d.tar.gz
tar -xvf jpegsrc.v9d.tar.gz
cd jpeg-9d
./configure CFLAGS="-arch arm64" CXXFLAGS="-arch arm64" LDFLAGS="-arch arm64
make
sudo make install

Note: here you need sudo to install it to /usr/local, however, you can specify where to install libJPEG by using --prefix=/dir in the ./configure command.

To check if your libJEPG is compiled with arm64 architecture

lipo -info /usr/local/lib/libjpeg.dylib

You will see something like this

Non-fat file: /usr/local/lib/libjpeg.dylib is architecture: arm64
  1. Compile Pillow for native Python 3.8 on Apple M1

Get Pillow-8.1.0 from pypi:

curl -L -O https://files.pythonhosted.org/packages/73/59/3192bb3bc554ccbd678bdb32993928cb566dccf32f65dac65ac7e89eb311/Pillow-8.1.0.tar.gz
tar -xvf Pillow-8.1.0.tar.gz
cd Pillow-8.1.0

Add the following lines after line 493 in setup.py, which tells the compiler to use -arch arm64 on Apple's M1 Arm Chip:

import platform
if platform.machine() == 'arm64':
    os.environ["ARCHFLAGS"] = "-arch arm64"

It will look like this:

Screen Shot 2021-01-22 at 12 34 24 PM

Save the setup.py. Then you can build and install it:

python3 setup.py build
python3 setup.py install --user

or

python3 setup.py build
sudo python3 setup.py install

Check the Pillow architecture:

% lipo -info _imaging.cpython-38-darwin.so 
Architectures in the fat file: _imaging.cpython-38-darwin.so are: x86_64 arm64 

You will get Pillow to work with libjpeg. You can do the same setup for OPENJPEG LIBTIFF etc.

--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version      Pillow 8.1.0
platform     darwin 3.8.2 (default, Nov  4 2020, 21:23:28)
             [Clang 12.0.0 (clang-1200.0.32.28)]
--------------------------------------------------------------------
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBIMAGEQUANT support not available
*** LIBTIFF support not available
*** FREETYPE2 support not available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
*** XCB (X protocol) support not available
--------------------------------------------------------------------
  1. Of course, you need the Xcode Command Line Tools
bschollnick commented 3 years ago

Sorry to bring this back up.

But I'm trying to find any documentation on adding M1 Native to Travis CI. Any docs or hints you could share? I'm trying to help out pymupdf, but I'm kind of guessing in the dark here since I've never touched Travis CI.

https://github.com/pymupdf/PyMuPDF/issues/834

cclauss commented 3 years ago

Nothing yet but https://docs.travis-ci.com/user/reference/osx/ is probably the place to look.

In general, GitHub Actions adopts new things more quickly.

deblagoj commented 3 years ago

In case this is helpful to anyone, here's a wheel I put together on my M1 - Pillow-8.0.1-cp39-cp39-macosx_11_0_arm64.whl.zip

Thank you !!! a lot !

radarhere commented 3 years ago

I've created https://github.com/python-pillow/pillow-wheels/pull/185 to add arm64 wheels to pillow-wheels. Unfortunately, it first requires macOS 11 pools - see https://github.com/actions/virtual-environments/issues/2486

alimehasin commented 3 years ago

For some reason I can't pip install Pillow if I don't have ffmpeg installed Platform: M1 MacBook runs macOS 11.2 Python: version 3.9.1 Pip: version 21.0.1

lixun910 commented 3 years ago

@alimehasin It could be the libxcb dependency issue. Try to use flag --disable-xcb, or install libxcb using brew (with “arch -arm64” if native).

jeregrine commented 3 years ago

For some reason I can't pip install Pillow if I don't have ffmpeg installed Platform: M1 MacBook runs macOS 11.2 Python: version 3.9.1 Pip: version 21.0.1

Thank you!

This solved my issue, brew install ffmpeg fixed the default install process for me.

jurihahn commented 3 years ago

if I try to sudo python3 -m pip install --upgrade Pillow

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/private/tmp/pip-install-or_9yvg6/pillow_fddc6b86afa6483bb48f047b1c40e2f9/setup.py", line 922, in raise RequiredDependencyException(msg) main.RequiredDependencyException:

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

cclauss commented 3 years ago

@jurihahn Did you try without sudo ?

Please provide the output of this command: uname -a ; brew --version ; python3 --version ; python3 -m pip --version