Installing Pillow with Mac OS X Mavericks (10.9.1)

拟墨画扇 提交于 2019-12-18 08:44:28

问题


I'm trying to install Pillow following the instruction:

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

The issue is that I got error with 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

The message says _jpeg_resync_to_restart is not found, I googled to try solve this problem as follows:

  1. Use brew to install Pillow: https://github.com/Homebrew/homebrew-python
  2. Install libjpeg and install from the source: http://www.thetoryparty.com/2010/08/31/pil-on-snow-leopard-_jpeg_resync_to_restart-error/

However, nothing works. Is there any way to install Pillow on Mavericks? I use Python 2.7: the default python interpreter.


回答1:


I confirm that following these steps I can install Pillow on Mavericks 10.9.2 with XCode 5

1:

brew install libtiff libjpeg webp littlecms

2: go to here https://pypi.python.org/pypi/Pillow/2.3.1 downalod the zip file and unzip it.

3: open a Terminal window and go to Pillow-2.3.1 folder in Terminal.

4: these two lines are extremely important because they will ignore the errors during installation of Pillow, without these two lines the setup cannot be finished (I am using python 2.7 so you may need to change whatever version you use):

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: run command

sudo python setup.py install

Done!




回答2:


Follow these steps

  1. update xcode on qppstore
  2. open the terminal an type:
    1. xcode-select --install
    2. su
    3. export CFLAGS=-Qunused-arguments
    4. export CPPFLAGS=-Qunused-arguments
    5. pip install pillow



回答3:


a friend told me how to fix this:

  1. sudo su -
  2. export CFLAGS=-Qunused-arguments
  3. pip install Image
  4. python
  5. from PIL import Image

by https://github.com/moskytw




回答4:


Had this problem in Nov 2015. Easiest solution for me was to install a precompiled binary of pillow using wheels:

pip install wheel
pip install --use-wheel pillow



回答5:


  1. Reinstall X11 from XQuartz.org
  2. Install the latest XCode
  3. Install the command line tools:

    xcode-select --install

Worked for me on mavericks



来源:https://stackoverflow.com/questions/21867277/installing-pillow-with-mac-os-x-mavericks-10-9-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!