I can't install 'pip install pil' in O

2019-05-11 19:15发布

Xcode is installed, python+django is up and running smoothly.

I'm writing Running:

pip install PIL

The Response:

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条回答
冷血范
2楼-- · 2019-05-11 19:59

You need to install the Xcode command line tools (which is not selected by default) when you install Xcode. Depending on your xcode version, you can either select to install the command line tools in the downloads panel of the preferences, or by reinstalling.

查看更多
登录 后发表回答