python - 如何在 Mac 上安装枕头?

标签 python ios django macos

我正在使用 Django 和 ImageField 进行工作,问题是在迁移我的模型时出现一条消息:

news.news_Paragraph.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
    HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow"

因此,当我尝试使用 pip install Pillow 安装 Pillow 时,出现了问题:

You are using pip version 7.1.0, however version 8.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting Pillow
  Using cached Pillow-3.2.0.zip
Installing collected packages: Pillow
  Running setup.py install for Pillow
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/81/hc0lc1y97v50nh7_m59rm39c0000gn/T/pip-build-P1duQd/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/81/hc0lc1y97v50nh7_m59rm39c0000gn/T/pip-VHKYOb-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-intel-2.7
    creating build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/__init__.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/_binary.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/_util.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/BdfFontFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/BmpImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/BufrStubImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ContainerIO.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/CurImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/DcxImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/DdsImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/EpsImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ExifTags.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/features.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/FitsStubImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/FliImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/FontFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/FpxImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/FtexImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/GbrImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/GdImageFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/GifImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/GimpGradientFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/GimpPaletteFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/GribStubImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/Hdf5StubImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/IcnsImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/IcoImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/Image.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageChops.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageCms.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageColor.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageDraw.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageDraw2.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageEnhance.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageFilter.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageFont.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageGrab.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageMath.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageMode.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageMorph.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageOps.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImagePalette.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImagePath.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageQt.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageSequence.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageShow.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageStat.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageTk.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageTransform.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImageWin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/ImtImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/IptcImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/Jpeg2KImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/JpegImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/JpegPresets.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/McIdasImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/MicImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/MpegImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/MpoImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/MspImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/OleFileIO.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PaletteFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PalmImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PcdImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PcfFontFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PcxImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PdfImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PixarImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PngImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PpmImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PsdImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PSDraw.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/PyAccess.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/SgiImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/SpiderImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/SunImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/TarIO.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/TgaImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/TiffImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/TiffTags.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/WalImageFile.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/WebPImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/WmfImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/XbmImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/XpmImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    copying PIL/XVThumbImagePlugin.py -> build/lib.macosx-10.11-intel-2.7/PIL
    running egg_info
    writing Pillow.egg-info/PKG-INFO
    writing top-level names to Pillow.egg-info/top_level.txt
    writing dependency_links to Pillow.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'Pillow.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.sh'
    no previously-included directories found matching 'docs/_static'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.landscape.yaml'
    warning: no previously-included files found matching 'appveyor.yml'
    warning: no previously-included files found matching 'build_children.sh'
    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
    writing manifest file 'Pillow.egg-info/SOURCES.txt'
    copying PIL/OleFileIO-README.md -> build/lib.macosx-10.11-intel-2.7/PIL
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/81/hc0lc1y97v50nh7_m59rm39c0000gn/T/pip-build-P1duQd/Pillow/setup.py", line 767, in <module>
        zip_safe=not debug_build(), )
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/install.py", line 53, in run
        return _install.run(self)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
        self.run_command('build')
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 337, in run
        self.build_extensions()
      File "/private/var/folders/81/hc0lc1y97v50nh7_m59rm39c0000gn/T/pip-build-P1duQd/Pillow/setup.py", line 512, in build_extensions
        ' using --disable-%s, aborting' % (f, f))
    ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/81/hc0lc1y97v50nh7_m59rm39c0000gn/T/pip-build-P1duQd/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/81/hc0lc1y97v50nh7_m59rm39c0000gn/T/pip-VHKYOb-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/81/hc0lc1y97v50nh7_m59rm39c0000gn/T/pip-build-P1duQd/Pillow

最佳答案

Pillow 正在使用 package-config 来定位其依赖库和包含路径。

可能的原因之一是您的 package-config 找不到正确的 zlib 路径。

检查你的 package-config 是否正常工作:

pkg-config zlib --libs

以下步骤对我有用:

brew install zlib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/Cellar/zlib/1.2.11/lib/pkgconfig/

关于python - 如何在 Mac 上安装枕头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37011356/

相关文章:

algorithm - 总结列表和列表列表的 Pythonic 方式

ios - 如何接收有关与我共享的记录更改的 cloudkit 通知?

Django:如何在注释中获取对象而不仅仅是外键?

django - 无法使用 pip 安装最新版本的 Django

Django 翻译不适用于生产

python - 为什么你可以在 for 循环中循环一个隐式元组,而不是 Python 中的一个理解?

Python 资源模块不起作用

python - 将正确的两个字符(如果有的话)设置为大写?

ios - 无法设置绑定(bind)(到 : UITableView) with RxSwift Variable asObservable()

ios - 选择一个按钮后,如何取消选择阵列中的所有其他按钮?