如何将 Python Pillow 作为 Homebrew 公式的必要条件?

Posted

技术标签:

【中文标题】如何将 Python Pillow 作为 Homebrew 公式的必要条件?【英文标题】:How to include Python Pillow as Homebrew formula requisite? 【发布时间】:2019-11-20 04:32:01 【问题描述】:

我曾经使用 Homebrew tap 公式来分发我自己维护的程序。但是,我无法处理一些使用 Pillow 的程序,因为 Homebrew 在尝试安装时会失败。

使用枕头的食谱示例:

class Monoshape < Formula
    include Language::Python::Virtualenv

    desc "Extracts monochromatic shapes"
    homepage "https://github.com/GlezSeoane/monoshape"
    url "https://github.com/GlezSeoane/monoshape/archive/v1.0.tar.gz"
    sha256 "6edbecfc60db6f91fba6e520769f811009743eec89d655c54e4e6006ad5b0dbb"

    depends_on "python"

    resource "filetype" do
        url "https://files.pythonhosted.org/packages/e8/53/298887541ae479f8467d4d23e028c6d15f9811da25c582297fd3869666b7/filetype-1.0.5.tar.gz"
        sha256 "17a3b885f19034da29640b083d767e0f13c2dcb5dcc267945c8b6e5a5a9013c7"
    end

    resource "Pillow" do
        url "https://files.pythonhosted.org/packages/51/fe/18125dc680720e4c3086dd3f5f95d80057c41ab98326877fc7d3ff6d0ee5/Pillow-6.1.0.tar.gz"
        sha256 "0804f77cb1e9b6dbd37601cee11283bba39a8d44b9ddb053400c58e0c0d7d9de"
    end

    def install
        virtualenv_install_with_resources
        man1.install "manpages/monoshape.1"
    end

    test do
        system "python", "-c", "'import monoshape.__main__'"
    end
end

尝试使用公式时的 Homebrew 错误输出:

brew reinstall --verbose --debug ./Formula/monoshape.rb
...
==> Downloading https://files.pythonhosted.org/packages/81/1a/6b2971adc1bca55b9a53ed1efa372acff7e8b9913982a396f3fa046efaf8/Pillow-6.0.0.tar.gz
/usr/bin/curl -q --show-error --user-agent Homebrew/2.1.7\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.14.5\)\ curl/7.54.0 --location --silent --head --request GET https://files.pythonhosted.org/packages/81/1a/6b2971adc1bca55b9a53ed1efa372acff7e8b9913982a396f3fa046efaf8/Pillow-6.0.0.tar.gz
Already downloaded: /Users/glezseoane/Library/Caches/Homebrew/downloads/ea7321a9356188da36d495f4135bfd7dfeb7add8558b773a6421e9096db03779--Pillow-6.0.0.tar.gz
==> Verifying ea7321a9356188da36d495f4135bfd7dfeb7add8558b773a6421e9096db03779--Pillow-6.0.0.tar.gz checksum
tar xof /Users/glezseoane/Library/Caches/Homebrew/downloads/ea7321a9356188da36d495f4135bfd7dfeb7add8558b773a6421e9096db03779--Pillow-6.0.0.tar.gz -C /private/tmp/d20190708-31029-1m7e24t
cp -pR /private/tmp/d20190708-31029-1m7e24t/Pillow-6.0.0/. /private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0
chmod -Rf +w /private/tmp/d20190708-31029-1m7e24t
==> /usr/local/Cellar/monoshape/1.0/libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed /private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0
Created temporary directory: /private/tmp/pip-ephem-wheel-cache-aihec4je
Created temporary directory: /private/tmp/pip-req-tracker-6pqza4qj
Created requirements tracker '/private/tmp/pip-req-tracker-6pqza4qj'
Created temporary directory: /private/tmp/pip-install-tjb4rpw6
Processing /private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0
  Created temporary directory: /private/tmp/pip-req-build-rgrd0jy0
  Added file:///private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0 to build tracker '/private/tmp/pip-req-tracker-6pqza4qj'
    Running setup.py (path:/private/tmp/pip-req-build-rgrd0jy0/setup.py) egg_info for package from file:///private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0
    Running command python setup.py egg_info
    running egg_info
    creating pip-egg-info/Pillow.egg-info
    writing pip-egg-info/Pillow.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/Pillow.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/Pillow.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/Pillow.egg-info/SOURCES.txt'
    reading manifest file 'pip-egg-info/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'
    no previously-included directories found matching 'docs/_static'
    warning: no previously-included files found matching '.appveyor.yml'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.codecov.yml'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.landscape.yaml'
    warning: no previously-included files found matching '.readthedocs.yml'
    warning: no previously-included files found matching 'azure-pipelines.yml'
    warning: no previously-included files found matching 'tox.ini'
    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 '.azure-pipelines'
    no previously-included directories found matching '.travis'
    writing manifest file 'pip-egg-info/Pillow.egg-info/SOURCES.txt'
  Source in /private/tmp/pip-req-build-rgrd0jy0 has version 6.0.0, which satisfies requirement Pillow==6.0.0 from file:///private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0
  Removed Pillow==6.0.0 from file:///private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0 from build tracker '/private/tmp/pip-req-tracker-6pqza4qj'
Skipping bdist_wheel for Pillow, due to binaries being disabled for it.
Installing collected packages: Pillow
  Created temporary directory: /private/tmp/pip-record-1a95g79y
  Running setup.py install for Pillow: started
    Running command /usr/local/Cellar/monoshape/1.0/libexec/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/tmp/pip-req-build-rgrd0jy0/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/tmp/pip-record-1a95g79y/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/monoshape/1.0/libexec/bin/../include/site/python3.7/Pillow
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-x86_64-3.7
    creating build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/MpoImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageMode.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PngImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/XbmImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PcxImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/SunImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/SpiderImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/TarIO.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/FitsStubImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/MpegImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/BdfFontFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/GribStubImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageStat.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PixarImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/GimpPaletteFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageColor.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ContainerIO.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/MspImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/MicImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/_version.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImtImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/GifImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PalmImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageQt.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageMath.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PaletteFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/FontFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PdfParser.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ExifTags.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageCms.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/FpxImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageChops.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/BufrStubImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PSDraw.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PcdImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageFilter.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageDraw2.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImagePath.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/DcxImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/JpegPresets.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/features.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageDraw.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/GimpGradientFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageWin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/IcoImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/_tkinter_finder.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/EpsImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/TgaImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageMorph.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/WalImageFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PcfFontFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/BlpImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageTk.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/GbrImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageOps.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PdfImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageShow.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageEnhance.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/WmfImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageGrab.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/WebPImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/FliImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/TiffTags.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/CurImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/_util.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/GdImageFile.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/TiffImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/IptcImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImagePalette.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/BmpImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageTransform.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/IcnsImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/McIdasImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/XpmImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/DdsImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageSequence.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PyAccess.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/_binary.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/Image.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/XVThumbImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/SgiImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PsdImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/JpegImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/ImageFont.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/PpmImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/PIL
    copying src/PIL/FtexImagePlugin.py -> build/lib.macosx-10.14-x86_64-3.7/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'
    no previously-included directories found matching 'docs/_static'
    warning: no previously-included files found matching '.appveyor.yml'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.codecov.yml'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.landscape.yaml'
    warning: no previously-included files found matching '.readthedocs.yml'
    warning: no previously-included files found matching 'azure-pipelines.yml'
    warning: no previously-included files found matching 'tox.ini'
    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 '.azure-pipelines'
    no previously-included directories found matching '.travis'
    writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
    running build_ext
    building 'PIL._imaging' extension
    creating build/temp.macosx-10.14-x86_64-3.7
    building 'PIL._imagingcms' extension
    building 'PIL._imagingft' extension
    building 'PIL._webp' extension
    creating build/temp.macosx-10.14-x86_64-3.7/src
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DHAVE_WEBPMUX -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_webp.c -o build/temp.macosx-10.14-x86_64-3.7/src/_webp.o
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_imagingft.c -o build/temp.macosx-10.14-x86_64-3.7/src/_imagingft.o
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_imagingcms.c -o build/temp.macosx-10.14-x86_64-3.7/src/_imagingcms.o
    creating build/temp.macosx-10.14-x86_64-3.7/src/libImaging
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DHAVE_LIBJPEG -DHAVE_OPENJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -DPILLOW_VERSION="6.0.0" -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_imaging.c -o build/temp.macosx-10.14-x86_64-3.7/src/_imaging.o
    src/_imagingft.c:25:10: fatal error: 'ft2build.h' file not found
    #include <ft2build.h>
             ^~~~~~~~~~~~
    1 error generated.
    building 'PIL._imagingtk' extension
    creating build/temp.macosx-10.14-x86_64-3.7/src/Tk
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Isrc/Tk -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_imagingtk.c -o build/temp.macosx-10.14-x86_64-3.7/src/_imagingtk.o
    clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk build/temp.macosx-10.14-x86_64-3.7/src/_webp.o -L/usr/local/Cellar/monoshape/1.0/libexec/lib -L/usr/local/lib -L/usr/lib -lwebp -lwebpmux -lwebpdemux -o build/lib.macosx-10.14-x86_64-3.7/PIL/_webp.cpython-37m-darwin.so
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Isrc/Tk -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/Tk/tkImaging.c -o build/temp.macosx-10.14-x86_64-3.7/src/Tk/tkImaging.o
    building 'PIL._imagingmath' extension
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_imagingmath.c -o build/temp.macosx-10.14-x86_64-3.7/src/_imagingmath.o
    clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk build/temp.macosx-10.14-x86_64-3.7/src/_imagingcms.o -L/usr/local/Cellar/monoshape/1.0/libexec/lib -L/usr/local/lib -L/usr/lib -llcms2 -o build/lib.macosx-10.14-x86_64-3.7/PIL/_imagingcms.cpython-37m-darwin.so
    building 'PIL._imagingmorph' extension
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_imagingmorph.c -o build/temp.macosx-10.14-x86_64-3.7/src/_imagingmorph.o
    clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk build/temp.macosx-10.14-x86_64-3.7/src/_imagingtk.o build/temp.macosx-10.14-x86_64-3.7/src/Tk/tkImaging.o -L/usr/local/Cellar/monoshape/1.0/libexec/lib -L/usr/local/lib -L/usr/lib -o build/lib.macosx-10.14-x86_64-3.7/PIL/_imagingtk.cpython-37m-darwin.so
    clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk build/temp.macosx-10.14-x86_64-3.7/src/_imagingmorph.o -L/usr/local/Cellar/monoshape/1.0/libexec/lib -L/usr/local/lib -L/usr/lib -o build/lib.macosx-10.14-x86_64-3.7/PIL/_imagingmorph.cpython-37m-darwin.so
    clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk build/temp.macosx-10.14-x86_64-3.7/src/_imagingmath.o -L/usr/local/Cellar/monoshape/1.0/libexec/lib -L/usr/local/lib -L/usr/lib -o build/lib.macosx-10.14-x86_64-3.7/PIL/_imagingmath.cpython-37m-darwin.so
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DHAVE_LIBJPEG -DHAVE_OPENJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -DPILLOW_VERSION="6.0.0" -I/usr/local/Cellar/freetype/2.10.0/include/freetype2 -I/usr/local/Cellar/openjpeg/2.3.1/include/openjpeg-2.3 -I/private/tmp/pip-req-build-rgrd0jy0/src/libImaging -I/usr/local/Cellar/monoshape/1.0/libexec/include -I/usr/local/include -I/usr/include -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/decode.c -o build/temp.macosx-10.14-x86_64-3.7/src/decode.o
    In file included from src/decode.c:869:
    /private/tmp/pip-req-build-rgrd0jy0/src/libImaging/Jpeg2K.h:11:10: fatal error: 'openjpeg.h' file not found
    #include <openjpeg.h>
             ^~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1
  Running setup.py install for Pillow: finished with status 'error'
Cleaning up...
  Removing source in /private/tmp/pip-req-build-rgrd0jy0
Removed build tracker '/private/tmp/pip-req-tracker-6pqza4qj'
ERROR: Command "/usr/local/Cellar/monoshape/1.0/libexec/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/tmp/pip-req-build-rgrd0jy0/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/tmp/pip-record-1a95g79y/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/monoshape/1.0/libexec/bin/../include/site/python3.7/Pillow" failed with error code 1 in /private/tmp/pip-req-build-rgrd0jy0/
Exception information:
Traceback (most recent call last):
  File "/usr/local/Cellar/monoshape/1.0/libexec/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 178, in main
    status = self.run(options, args)
  File "/usr/local/Cellar/monoshape/1.0/libexec/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 414, in run
    use_user_site=options.use_user_site,
  File "/usr/local/Cellar/monoshape/1.0/libexec/lib/python3.7/site-packages/pip/_internal/req/__init__.py", line 58, in install_given_reqs
    **kwargs
  File "/usr/local/Cellar/monoshape/1.0/libexec/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 951, in install
    spinner=spinner,
  File "/usr/local/Cellar/monoshape/1.0/libexec/lib/python3.7/site-packages/pip/_internal/utils/misc.py", line 776, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip._internal.exceptions.InstallationError: Command "/usr/local/Cellar/monoshape/1.0/libexec/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/tmp/pip-req-build-rgrd0jy0/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/tmp/pip-record-1a95g79y/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/monoshape/1.0/libexec/bin/../include/site/python3.7/Pillow" failed with error code 1 in /private/tmp/pip-req-build-rgrd0jy0/
/usr/bin/curl --version
/usr/libexec/java_home --xml --failfast
/usr/libexec/java_home --xml --failfast
/usr/local/Homebrew/Library/Homebrew/debrew.rb:13:in `raise'
BuildError: Failed executing: /usr/local/Cellar/monoshape/1.0/libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed /private/tmp/monoshape--Pillow-20190708-31029-1w8theb/Pillow-6.0.0

自 macOS Mojave 10.14.5 起更新了 Python 3.7 和 Homebrew

【问题讨论】:

【参考方案1】:

您可能需要包含额外的 depends_on 子句来帮助 Pillow 定位已编译的库:例如,depends_on "openjpeg"(提供 openjpeg.h)。

【讨论】:

以上是关于如何将 Python Pillow 作为 Homebrew 公式的必要条件?的主要内容,如果未能解决你的问题,请参考以下文章

如何在 python 中使用 Pillow 创建日历?

python如何随机显示动漫背景

如何强制 Pillow 将图像调整为任意大小?

❤️【Python从入门到精通】(二十七)更进一步的了解Pillow吧!

将 python-pillow 添加到 buildroot

Python3中Pillow(PIL)介绍