I am trying to plot a graph using matplotlib:
#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;
int main() {
plt::plot({1,2,3,4});
plt::show();
}
However, when I hit compile I get the following error:
/usr/local/include/matplotlibcpp.h:19:12:
fatal error: 'numpy/arrayobject.h' file not found
This is how I compile:
g++ main.cpp -std=c++11 -I/usr/include/python2.7 -lpython2.7
Please can someone explain what the problem is and how I can solve it. Thanks in advance.
That error indicates that the numpy headers were not found in one of the default locations like /usr/include
.
The solution is to find the include folder of your numpy installation and point the compiler to it with a -I
flag.
Your command line should look something like
g++ main.cpp -std=c++11 -I/usr/include/python2.7 -lpython2.7
我通过在mapplotlibcpp.h顶部添加“ #define WITHOUT_NUMPY”标志来解决此问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.