几天来,我一直在努力为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。
最佳答案
只需编辑/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/[email protected]/msg00215.html
关于python - 由于Coacoa错误,在Mac OS X Mavericks上通过pip安装Matplotlib是否失败?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20737128/