我无法在Osx中安装'pip install pil'

时间:2012-09-18 20:53:08

标签: django macos terminal python-imaging-library pip

安装了Xcode,python + django正常运行。

我正在写Running:

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

WHY!?

1 个答案:

答案 0 :(得分:8)

安装Xcode时,需要安装Xcode命令行工具(默认情况下未选中)。根据您的xcode版本,您可以选择在首选项的下载面板中安装命令行工具,也可以重新安装。