6

我正在尝试按照说明安装 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未找到,我用谷歌搜索尝试解决此问题,如下所示:

  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 解释器。

4

6 回答 6

7

我确认按照这些步骤,我可以使用 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

完毕!

于 2014-03-28T17:40:50.650 回答
6

按着这些次序

  1. 在 qppstore 上更新 xcode
  2. 打开终端类型:
    1. xcode-select --install
    2. su
    3. export CFLAGS=-Qunused-arguments
    4. export CPPFLAGS=-Qunused-arguments
    5. pip install pillow
于 2014-05-04T04:33:08.057 回答
3

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

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

通过https://github.com/moskytw

于 2014-04-28T05:58:06.647 回答
1

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

pip install wheel
pip install --use-wheel pillow
于 2015-11-12T15:24:05.413 回答
0
  1. 从 XQuartz.org 重新安装 X11
  2. 安装最新的 XCode
  3. 安装命令行工具:

    xcode-选择--安装

在小牛队为我工作

于 2014-02-27T18:43:57.423 回答
0

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

pip uninstall pillow
pip install Pillow==2.5.0

轰呀宝贝!

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

于 2020-06-03T23:12:16.643 回答