我一直在努力为python安装matplotlib库几天了。我有freetype,XCode,X11和绑定的绑定,但现在当我尝试安装matplotlib时,我收到以下错误:
building 'matplotlib.backends._macosx' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2
-DNDEBUG -g -O3 -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_backends__macosx_ARRAY_API
-DPYCXX_ISO_CPP_LIB=1 -I/Library/Frameworks/Python.framework/Versions/2.7/lib
/python2.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/include
-I/usr/X11/include -I/opt/local/include -I. -Iagg24/include
-I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
-c src/_macosx.m
-o build/temp.macosx-10.6-intel-2.7/src/_macosx.o
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:161,
from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
from src/_macosx.m:1:
/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:16:
error: expected ‘,’ or ‘}’ before ‘__attribute__’
这附带了一些关于弃用的numpy API的警告,但这些似乎没有引起任何问题。谁能告诉我这里的问题是什么?
为了记录,我正在使用gcc-4.2。
答案 0 :(得分:1)
只需编辑/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:
sudo nano /System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h
更改第16行:
NSUserNotificationActivationTypeReplied NS_AVAILABLE(10_9, NA) = 3
为:
NSUserNotificationActivationTypeReplied /* NS_AVAILABLE(10_9, NA) */ = 3
然后重试安装matplotlib:
sudo pip install matplotlib
这为我解决了!
来源:https://www.mail-archive.com/macosx-port-dev@openjdk.java.net/msg00215.html
答案 1 :(得分:0)
检查which -a gcc-4.2
的输出。如果它/usr/bin/gcc-4.2
你没有使用Xcode提供的gcc。要解决此问题,请运行前缀为CC=/usr/bin/gcc
的构建命令(或pip等)。这应该可以解决这个错误。