我试图在Mac 10.7.4上安装PIL,但是几个小时后,尝试失败了。一直以来,我都遇到了同样的问题,在下面的pastebin链接中提供了详细信息。启发我!!
设置
tbc:~ mystic$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python巴斯丁
我从几个来源搜索和尝试:
Python 2.7.2 (v2.7.2:8527427914a2,2011年6月11日,15:22:34) GCC 4.2.1 (Apple Inc. . build 5666) (点3)在达尔文类型“帮助”、“版权”、“信用”或“许可”上获得更多信息。>>>导入图像跟踪(最近一次调用):文件"",第1行,在ImportError: No模块命名的图像>>>导入PIL跟踪(最近调用):文件"",第1行,在ImportError:没有模块名为PIL >>>
按照jdi的建议进行编辑,但仍在运行相同的问题,如上面的pastebin链接所示。
tbc:jpeg-8c mystic$ xcode-select -version
xcode-select version 2003.
tbc:jpeg-8c mystic$ which xcode-select
/usr/bin/xcode-select
tbc:jpeg-8c mystic$ xcode-select -print-path
/Applications/Xcode.app/Contents/Developer
tbc:jpeg-8c mystic$此外,我还按照"the paul“的建议尝试了自制。
tbc:cellar mystic$ brew link jpeg
Linking /usr/local/Cellar/jpeg/8d... 3 symlinks created
tbc:cellar mystic$ brew install pil
Error: pil-1.1.7 already installed
tbc:cellar mystic$ brew uninstall pil
Uninstalling /usr/local/Cellar/pil/1.1.7...
tbc:cellar mystic$ brew install pil
==> Downloading http://effbot.org/downloads/Imaging-1.1.7.tar.gz
Already downloaded: /Library/Caches/Homebrew/pil-1.1.7.tar.gz
==> python setup.py build_ext
==> python setup.py install --prefix=/usr/local/Cellar/pil/1.1.7
==> Caveats
This formula installs PIL against whatever Python is first in your path.
This Python needs to have either setuptools or distribute installed or
the build will fail.
Warning: Non-executables were installed to "bin".
Installing non-executables to "bin" is bad practice.
The offending files are:
/usr/local/Cellar/pil/1.1.7/bin/pilfont.py
==> Summary
/usr/local/Cellar/pil/1.1.7: 174 files, 2.0M, built in 15 seconds
tbc:cellar mystic$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pil
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL这是.pip的日志
它在抱怨
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory但是stdarg.h文件在同一个位置。
我不明白为什么它试图在MacOSX10.6.sdk中定位,因为我目前版本的Lion是MacOSX10.7.sdk。
快疯了!
发布于 2012-05-18 20:05:05
如果您在Lion上使用最新的XCode,那么您可能会遇到的一个问题是,它们移动了开发人员SDK的位置。那些期望他们生活在/Developer/中的软件包将不再按需要找到他们。
请参阅这篇关于具体内容的文章:
sdk-xcode/
但总而言之,您可能需要运行的是:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
指向新的地点。
手动修复可能只是将/Applications/Xcode.app/Contents/Developer/... => /Developer/...中的SDK符号链接起来,但是我首先尝试xcode-select工具。
更新:基于新更新的一些更多建议
首先,我无法从您发布的内容中判断PIL是否因为SDK而无法构建。如果它成功构建,并且您正在使用标准的apple python,那么很可能不是在您自己的python路径中。
$ python
>>> import sys
>>> sys.path.append("/usr/local/lib/python2.7/site-packages")
>>> from PIL import Image如果仍然存在错误,那么我认为问题仍然与缺少SDK位置有关。您可以使用以下方法将SDK的新位置符号链接到旧位置:
mkdir -p -v /Developer/SDKs
ln -s /Applications/Xcode.app/Contents/Developer/MacOSX10.6.sdk /Developer/SDKs/MacOSX10.6.sdk或者,您可以尝试在构建pil时显式设置sdk路径:
brew remove pil
export SDKROOT=/Applications/Xcode.app/Contents/Developer/MacOSX10.6.sdk
brew install pil发布于 2012-05-18 19:32:11
发布于 2017-02-04 11:23:37
如果安装了自制软件,这将完成以下工作:
brew install pillowhttps://stackoverflow.com/questions/10657363
复制相似问题