Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2

前端 未结 12 2205
一向
一向 2020-12-08 01:12

I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation.

I then installed Python

相关标签:
12条回答
  • 2020-12-08 01:50

    Following steps worked for me:

    $ brew install pip
    $ export ARCHFLAGS="-arch i386 -arch x86_64"
    $ pip install pil
    
    0 讨论(0)
  • 2020-12-08 01:51

    May be you should try pre-build universal binaries from pythonmac site

    http://pythonmac.org/packages/py25-fat/index.html

    These are for python2.5 , with python2.5 included(so may or may not be usable for you), I have been using it since I had problem using self build PIL with py2app.

    0 讨论(0)
  • 2020-12-08 01:58

    Modified Answer

    Here are the steps that I took to successfully install PIL on Mac OS X 10.6 (without using MacPorts or Fink).

    1. Install readline

      cd ~/src
      curl -O ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
      tar -xvzf readline-6.0.tar.gz
      cd readline-6.0
      ./configure  
      make  
      sudo make install
      
    2. Install gbdm

      cd ~/src
      curl -O ftp://mirror.anl.gov/pub/gnu/gdbm/gdbm-1.8.3.tar.gz
      tar -xvzf gbdm-1.8.3.tar.gz
      cd gdbm-1.8.3
      # Need to modify Makefile.in
      perl -pi -e 's/BINOWN = bin/BINOWN = root/' Makefile.in
      perl -pi -e 's/BINGRP = bin/BINGRP = wheel/' Makefile.in
      ./configure
      make
      sudo make install
      
    3. Compile the latest Python 2.6.2+ from the Mercurial Repo

      cd ~/development
      hg clone http://code.python.org/hg/branches/release2.6-maint/ python-release2.6-maint.hg
      cd python-release2.6-main.hg
      ./configure --enable-framework MACOSX_DEPLOYMENT_TARGET=10.6
      make
      sudo make frameworkinstall
      

      Note: I did receive the following errors after running make. However, I continued on as I wasn't worried about missing these modules, and I was able to successfully install PIL.

      Failed to find the necessary bits to build these modules:
      _bsddb             dl                 imageop         
      linuxaudiodev      ossaudiodev        spwd            
      sunaudiodev                                           
      To find the necessary bits, look in setup.py in detect_modules() for the module's name.
      
      
      Failed to build these modules:
      Nav                                                   
      
      running build_scripts
      
    4. Update .bash_profile for the new Python 2.6.2+ and for virtualenvwrapper

      # Set PATH for MacPython 2.6 if Python2.6 is installed
      if [ -x /Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 ]; then
          PATH="/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}"
          export PATH
      fi
      
      # MDR April 23, 2009: Added for virtualenvwrapper
      if [ -x   /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper_bashrc ]; then
          export WORKON_HOME=$HOME/.virtualenvs
          export PIP_VIRTUALENV_BASE=$WORKON_HOME
          source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper_bashrc
      fi
      
    5. Install easy_install, pip, virtualenv, and virtualenvwrapper for Python 2.6.2+

      curl -O http://peak.telecommunity.com/dist/ez_setup.py
      sudo python ez_setup.py
      sudo easy_install pip
      sudo easy_install virtualenv
      sudo easy_install virtualenvwrapper
      
    6. Create a virtualenv and then use pip to install PIL

      mkvirtualenv pil-test
      cdvirtualenv
      easy_install pip
      pip install http://effbot.org/downloads/Imaging-1.1.6.tar.gz
      

    Note: I was not able to install PIL using pip install pil, so I installed from the URL as shown above.

    Original Answer

    From what I can see in your pip-log.txt file it appears that you installed Python 2.6.2 using the Mac Installer Disk Image from Python.org released on April 16, 2009. Can you confirm this?

    From the pip log, gcc failed with exit status 1. The offending gcc command from your pip log is as follows:

    gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/Library/Frameworks/Python.framework/Versions/2.6/include -I/usr/local/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _imaging.c -o build/temp.macosx-10.3-fat-2.6/_imaging.o
    

    This appears to be a problem related to Snow Leopard changing the default value for the -arch flag from i386 to x86-64 according to Ronald Oussoren in Message 92083 of Python Issue 6802. There is a patch available Python 2.6.2, but it has not been integrated into the Mac Installer Disk Image.

    Your best solution that doesn't involve MacPorts or Fink would probably be to compile and install Python from the 2.6 release branch from either the Mercurial Python Repository or the Subversion Python Repository. According to Message 92315 of Issue 6802, Ronald Oussoren fixed this in Revision r74686.

    I've been seeing similar errors using Python 2.6.2 installed from the Mac Disk Image while trying to then install Fabric in a virtualenv, so I plan to compile and install from the 2.6 release maintenance branch. If you want, I'll update when successful.

    0 讨论(0)
  • 2020-12-08 01:58

    Solved in 2 steps:

    Step 1: Uninstalled and Installed Xcode, suggested here: http://binarylionstudios.com/blog/2011/01/30/error-stdarg.h-no-such-file-or-directory/

    to remove Xcode properlly follow this answer: How to fully remove Xcode 4

    sudo /Developer/Library/uninstall-devtools --mode=all

    use the install Xcode.app after you restart your mac

    Step 2: after xcode was reinstalled, the installation failed

    unable to execute gcc-4.2: No such file or directory PIL

    to resolve that i followed this post: http://aravir-rose.blogspot.com/2011/12/installing-python-27s-imaging-library.html

    Good luck!

    0 讨论(0)
  • 2020-12-08 02:04

    I found a simpler method. sudo port install python26 sudo port install python_select

    Then use python_select set python26 as default.

    Then just install PIL as normal.

    0 讨论(0)
  • 2020-12-08 02:05

    I was able to get PIP installed with SL's Python using these instructions:

    http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/

    0 讨论(0)
提交回复
热议问题