Python Matplotlib-找不到Numpy头文件
我正在尝试使用matplotlib绘制图形:Python Matplotlib-找不到Numpy头文件,python,c++,macos,matplotlib,Python,C++,Macos,Matplotlib,我正在尝试使用matplotlib绘制图形: #include "matplotlibcpp.h" namespace plt = matplotlibcpp; int main() { plt::plot({1,2,3,4}); plt::show(); } 但是,当我点击compile时,我得到以下错误: /usr/local/include/matplotlibcpp.h:19:12: fatal error: 'numpy/arrayobject.h' file n
#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;
int main() {
plt::plot({1,2,3,4});
plt::show();
}
但是,当我点击compile时,我得到以下错误:
/usr/local/include/matplotlibcpp.h:19:12:
fatal error: 'numpy/arrayobject.h' file not found
我是这样编译的:
g++ main.cpp -std=c++11 -I/usr/include/python2.7 -lpython2.7
请有人解释一下问题是什么以及我如何解决它。提前感谢。该错误表示在默认位置(如
/usr/include
)中找不到numpy头
解决方案是找到numpy安装的include文件夹,并使用-I
标志将编译器指向该文件夹
您的命令行应该类似于
g++ main.cpp -std=c++11 -I/usr/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -lpython2.7
g++main.cpp-std=c++11-I/usr/include/python2.7-I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/核心/包括-lpython2.7
该错误表示在默认位置(如
/usr/include
)中找不到numpy头
解决方案是找到numpy安装的include文件夹,并使用-I
标志将编译器指向该文件夹
您的命令行应该类似于
g++ main.cpp -std=c++11 -I/usr/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -lpython2.7
g++main.cpp-std=c++11-I/usr/include/python2.7-I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/核心/包括-lpython2.7
我通过在mapplotlibcpp.h顶部添加“#定义而不使用_NUMPY”标志来解决此问题我通过在mapplotlibcpp.h顶部添加“#定义而不使用_NUMPY”标志来解决此问题显示如何编译无问题。我已经更新了这个问题。你需要一个-I标志,其中包含numpy headersIt现在编译的文件夹。谢谢您希望我在upvote中添加答案并选择,还是希望删除该问题?演示如何编译NoProb。我已经更新了这个问题。你需要一个-I标志,其中包含numpy headersIt现在编译的文件夹。谢谢您希望我在upvote和select中添加一个答案,还是只希望删除该问题?