2012-09-18 115 views
3

安裝了Xcode,python + django啓動並運行平穩。我無法在Osx上安裝'pip install pil'

我寫運行:

pip install PIL 

的迴應:

Downloading/unpacking PIL 
    Running setup.py egg_info for package PIL 
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py 

Installing collected packages: PIL 
    Running setup.py install for PIL 
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py 
    --- using frameworks at /System/Library/Frameworks 
    building '_imaging' extension 
    clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o 
    unable to execute clang: No such file or directory 
    error: command 'clang' failed with exit status 1 
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/var/folders/3_/tp_3vp9966dc65phynpzl04h0000gn/T/pip-build/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/3_/tp_3vp9966dc65phynpzl04h0000gn/T/pip-QFMx2t-record/install-record.txt --single-version-externally-managed: 
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py 

running install 

running build 

running build_py 

running build_ext 

--- using frameworks at /System/Library/Frameworks 

building '_imaging' extension 

clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o 

unable to execute clang: No such file or directory 

error: command 'clang' failed with exit status 1 

---------------------------------------- 
Command /usr/bin/python -c "import setuptools;__file__='/var/folders/3_/tp_3vp9966dc65phynpzl04h0000gn/T/pip-build/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/3_/tp_3vp9966dc65phynpzl04h0000gn/T/pip-QFMx2t-record/install-record.txt --single-version-externally-managed failed with error code 1 in /var/folders/3_/tp_3vp9966dc65phynpzl04h0000gn/T/pip-build/PIL 
Traceback (most recent call last): 
    File "/usr/local/bin/pip", line 8, in <module> 
    load_entry_point('pip==1.2', 'console_scripts', 'pip')() 
    File "/Library/Python/2.7/site-packages/pip/__init__.py", line 111, in main 
    return command.main(args[1:], options) 
    File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 145, in main 
    temp = tempfile.NamedTemporaryFile(delete=False) 
NameError: global name 'tempfile' is not defined 

爲什麼!?

+1

http://stackoverflow.com/questions/12180225/how-do-i-build-pil-on-os-x-mountain-lion的副本。 –

+2

@LoïsDiQual這與您鏈接的人看起來是不同的問題。 – James

回答

8

當您安裝Xcode時,您需要安裝Xcode命令行工具(默認情況下未選中)。根據您的xcode版本,您可以選擇在首選項的下載面板中安裝命令行工具,或者通過重新安裝。

+1

你說得對。我在這裏閱讀了相同的信息http://python-on-mac.blogspot.com/2013/02/prepare-your-mac-to-work-in-python.html –