Python 2.7 Matplotlib无法使用Python 2.7.3在Mac OS 10.8.2上安装

Python 2.7 Matplotlib无法使用Python 2.7.3在Mac OS 10.8.2上安装,python-2.7,matplotlib,installation,osx-lion,Python 2.7,Matplotlib,Installation,Osx Lion,我已经安装了numpy,当我去安装Matplotlib时,它会失败。不管我用什么方法安装它。下面是我收到的错误 gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 - DNDEBUG -g -O3 -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 - I/usr/local/include -I/usr/

我已经安装了numpy,当我去安装Matplotlib时,它会失败。不管我用什么方法安装它。下面是我收到的错误

gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -    
DNDEBUG -g -O3 -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -  
I/usr/local/include -I/usr/include -I/usr/X11/include -I/opt/local/include -
I/usr/local/include -I/usr/include -I. -
I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I. -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/_png.cpp -o build/temp.macosx-10.6-intel-2.7/src/_png.o

src/_png.cpp:23:20: error: png.h: No such file or directory

src/_png.cpp:66: error: variable or field ‘write_png_data’ declared void

src/_png.cpp:66: error: ‘png_structp’ was not declared in this scope

src/_png.cpp:66: error: ‘png_bytep’ was not declared in this scope

src/_png.cpp:66: error: ‘png_size_t’ was not declared in this scope

src/_png.cpp:23:20: error: png.h: No such file or directory

src/_png.cpp:66: error: variable or field ‘write_png_data’ declared void

src/_png.cpp:66: error: ‘png_structp’ was not declared in this scope

src/_png.cpp:66: error: ‘png_bytep’ was not declared in this scope

src/_png.cpp:66: error: ‘png_size_t’ was not declared in this scope

lipo: can't figure out the architecture type of:   
/var/folders/c9/xzv35t2n3ld9lgjrtl0vd0xr0000gn/T//ccwRj4ny.out

error: command 'gcc-4.2' failed with exit status 1

----------------------------------------

Command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -
c "import setuptools;__file__='/var/folders/c9/xzv35t2n3ld9lgjrtl0vd0xr0000gn/T/pip-
build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'),
__file__, 'exec'))" install --record /var/folders/c9/xzv35t2n3ld9lgjrtl0vd0xr0000gn/T/pip-
udXluz-record/install-record.txt --single-version-externally-managed failed with error
code 1 in /var/folders/c9/xzv35t2n3ld9lgjrtl0vd0xr0000gn/T/pip-build/matplotlib
Storing complete log

文件
png.h
安装了,这是构建的要求


请注意,libpng的更高版本(1.5和1.6是完全不同的,1.2或更高版本的需求规范可能不适合您,因为不兼容。我已经成功地将libpng 1.2与matplotlib一起使用,但没有尝试过最新的1.6系列。

在Mac上安装Python的最佳方法是使用一键式安装程序
Enthow Python分发
并避免编译时依赖项。它有一个适用于Mac OS X[0]的32位免费版本。
Matplotlib
libpng
(这似乎是您的依赖项)包含在免费版本中[1]

[0]


[1]

看起来你没有libpng。根据你选择的背景,你可能还会发现其他编译问题。如果你想从源代码处编译,你应该了解要求并安装它们。我通常会避免从源代码处编译,特别是对于OSX,当有这么多其他选项可用时。我建议d安装matplotlib附带的。