0

I am trying to use matplotlib c++ and I have the header file in my working directory. The only problem is that the dependency (Python.h) cannot be opened. I have tried looking around but I don't really understand what to do. When I searched my computer for Python.h, I have found that they are all along the path of:

/Users/name/opt/anaconda3/pkgs/python-3.9.12-hdfd78df_0/include/python3.9

because I have Python 3.8, 3.9, and 3.10 installed. I am a library noob so all of these locations and package managers like conda and connecting with c++ is confusing to me. Moving Python.h to my working directory just causes compiling "fatal errors" of a dependency of Python.h, "patchlevel.h". Also why does the matplotlib header file include Python.h in <> and not quotes because it's a file? Sorry for so many questions.

destroyer806
  • 23
  • 1
  • 1
  • 5
  • Can't help with the main question, but `<>` tells the compiler's preprocessor to search for the include in the external libraries and `""` tells the compiler to look in the program source directory. Usually if the compiler can't find the file in the specified location it will check the other, but I don't think this is guaranteed. See [What is the difference between #include and #include "filename"?](https://stackoverflow.com/questions/21593) for more information. – user4581301 Jun 15 '22 at 00:20
  • You need to tell the compiler what directory to look in for `Python.h`. How to do this depends on what compiler you are using. If you are using Visual Studio you right click on the solution name in Solution Explorer and go to Properties->C/C++->General->Additional Include Directories. Or, you can add the desired directory to the PATH environment variable in Windows. – dmedine Jun 15 '22 at 00:28
  • Sorry the comment above assumes Windows. Usually /Users/... indicates a Windows OS. – dmedine Jun 15 '22 at 00:34
  • Sorry! I forgot to specify that this is on Mac. I have tried to look for include directories in VScode on Mac but I cannot find it – destroyer806 Jun 15 '22 at 01:08

0 Answers0