【问题标题】:Installing Pillow with Mac OS X Mavericks (10.9.1)使用 Mac OS X Mavericks (10.9.1) 安装 Pillow
【发布时间】:2014-02-18 22:55:18
【问题描述】:

我正在尝试按照说明安装 Pillow:

http://pillow.readthedocs.org/en/latest/installation.html#mac-os-x-installation

问题是python -c 'from PIL import Image 出错。

 python -c "from PIL import Image"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 53, in <module>
    from PIL import _imaging as core
ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2): 
             Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Library/Python/2.7/site-packages/PIL/_imaging.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/PIL/_imaging.so

消息说_jpeg_resync_to_restart未找到,我google了下尝试解决这个问题:

  1. 使用brew安装Pillowhttps://github.com/Homebrew/homebrew-python
  2. 安装 libjpeg 并从源安装:http://www.thetoryparty.com/2010/08/31/pil-on-snow-leopard-_jpeg_resync_to_restart-error/

但是,没有任何效果。有没有办法在 Mavericks 上安装 Pillow?我使用 Python 2.7:默认的 Python 解释器。

【问题讨论】:

    标签: python macos python-imaging-library osx-mavericks pillow


    【解决方案1】:

    我确认按照这些步骤,我可以使用 XCode 5 在 Mavericks 10.9.2 上安装 Pillow

    1:

    brew install libtiff libjpeg webp littlecms
    

    2:到这里https://pypi.python.org/pypi/Pillow/2.3.1下载zip文件并解压。

    3:打开终端窗口,进入终端中的 Pillow-2.3.1 文件夹。

    4:这两行非常重要,因为它们会在安装 Pillow 时忽略错误,如果没有这两行,设置将无法完成(我使用的是 python 2.7,因此您可能需要更改您使用的任何版本):

    sudo sed -i '' -e 's/-mno-fused-madd//g' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py
    sudo rm /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.pyc
    

    5:运行命令

    sudo python setup.py install
    

    完成!

    【讨论】:

    • 编译完Pillow的Tests目录下的所有测试都通过了吗?
    • 不,我没有检查测试目录。但是在安装之前我遇到了错误。安装后我运行了这个命令python -c "from PIL import Image"没有显示错误。
    • 顺便说一下我引用issue link
    【解决方案2】:

    按照这些步骤进行

    1. 在 qppstore 上更新 xcode
    2. 打开终端类型:
      1. xcode-select --install
      2. su
      3. export CFLAGS=-Qunused-arguments
      4. export CPPFLAGS=-Qunused-arguments
      5. pip install pillow

    【讨论】:

    • 如何解释每个步骤的作用以及为什么需要它?
    【解决方案3】:

    一位朋友告诉我如何解决这个问题:

    1. 须藤苏-
    2. 导出 CFLAGS=-Qunused-arguments
    3. 点安装图片
    4. 蟒蛇
    5. 从 PIL 导入图像

    https://github.com/moskytw

    【讨论】:

    • 请注意,这会全局安装 Django。
    【解决方案4】:

    在 2015 年 11 月遇到这个问题。对我来说最简单的解决方案是使用轮子安装枕头的预编译二进制文件:

    pip install wheel
    pip install --use-wheel pillow
    

    【讨论】:

      【解决方案5】:
      1. 从 XQuartz.org 重新安装 X11
      2. 安装最新的 XCode
      3. 安装命令行工具:

        xcode-select --install

      在小牛队为我工作

      【讨论】:

      • your answer 的完全重复,停止发布重复的答案,不要创建冗余。
      【解决方案6】:

      安装早期版本的 Pillow 对我有用

      pip uninstall pillow
      pip install Pillow==2.5.0
      

      Boom Ya Baby!

      现在运行 MacOSX 10.8.5 from PIL import Image 不会引发错误。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-04-24
        • 1970-01-01
        • 1970-01-01
        • 2014-03-23
        • 2013-11-11
        • 2013-11-17
        • 1970-01-01
        相关资源
        最近更新 更多