matplotlib-cpp icon indicating copy to clipboard operation
matplotlib-cpp copied to clipboard

Python.h: No such file or directory even after using "quick fix"

Open michioD opened this issue 2 years ago • 2 comments

Python version: 3.8.1 I added Python.h and Numpy on the path with a json file.

I tried compiling the animation example. And I got the following error:

PS C:\CPPScripts\cpp_tmp_scripts\matplotlib-cpp\examples> g++ .\animation.cpp -o animation
In file included from .\animation.cpp:3:
.\../matplotlibcpp.h:5:10: fatal error: Python.h: No such file or directory
 #include <Python.h>
          ^~~~~~~~~~
compilation terminated.

Apparently matlabplotcpp.h still doesn't see the Python.h file despite I put in the required paths.

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\Users\\foo\\AppData\\Local\\Programs\\Python\\Python38-32\\include",
                "C:\\Users\\foo\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\numpy\\core\\include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\Strawberry\\c\\bin\\gcc.exe",
            "cStandard": "gnu17",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "windows-gcc-x64"
        }
    ],
    "version": 4
}

How do I fix this?

michioD avatar Feb 01 '23 23:02 michioD

had you resolve it? I metting same quetion -. -

alexsneering avatar May 24 '24 06:05 alexsneering

i use python3.11

change the .vscode folder and modify task.json, after that build it CTRL+SHIFT+B

{ "version": "2.0.0", "tasks": [ { "type": "cppbuild", "label": "C/C++: g++.exe build active file", "command": "C:\msys64\ucrt64\bin\g++.exe", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-I${workspaceFolder}", "-IC:/Users/mywindows/AppData/Local/Programs/Python/Python311/include", "-IC:/Users/mywindows/AppData/Local/Programs/Python/Python311/Lib/site-packages/numpy/core/include", "-L/C:/Users/mywindows/AppData/Local/Programs/Python/Python311/libs", "C:/Users/mywindows/AppData/Local/Programs/Python/Python311/libs/python311.lib", "-o", "${fileDirname}\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "Task generated by Debugger." } ] }

``

adi-candra avatar Jul 07 '25 19:07 adi-candra