我正在尝试在 Mac OSX 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, 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 Image Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Image >>> import PIL Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 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
疯了!!!
答案 0 :(得分:9)
如果你在Lion上,使用最新的XCode,那么潜在的问题是他们移动了开发人员SDK的位置。希望它们存在/Developer/
的软件包将无法再根据需要找到它们。
参考这篇文章有关细节:
http://www.agile-workers.com/web/2012/03/qt-qmake-osx_sdk-xcode/
但总的来说,您可能需要做的是:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
指向新的位置。
手动修复可能只是从/Applications/Xcode.app/Contents/Developer/...
=&gt;符号链接SDK。 /Developer/...
,但我会首先尝试使用xcode-select工具。
更新:根据您的新更新提供更多建议
首先,我无法告诉您发布的内容是否因为SDK而无法构建PIL。如果它成功构建,并且您正在使用标准的apple python,那么自制的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
答案 1 :(得分:1)
简易解决方案:
:)
答案 2 :(得分:0)
如果你安装了Homebrew,这将完成工作:
brew install pillow