OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Cmd doesnt recognize Python.h, although i specified the path in the c_cpp_properties.json file

  • Thread starter Thread starter Mendo
  • Start date Start date
M

Mendo

Guest
I wanted to run python code from my .c file.

This is my code:

Code:
#include <stdio.h>
#include <conio.h>
#include <Python.h>

int main()
{
    char filename[] = "d.py";
    FILE* fp;

    Py_Initialize();

    fp = _Py_fopen(filename, "r");
    PyRun_SimpleFile(fp, filename);

    Py_Finalize();
    return 0;
}

I have added a path to my c_cpp_properties.json that leads to the Python312/include

This is my c_cpp_properties.json code:

Code:
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${default}",
                "C:/Program Files/Python312/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22621.0",
            "compilerPath": "cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

When I compile the code it throws an error:

b.c:3:20: fatal error: Python.h: No such file or directory #include <Python.h> ^ compilation terminated.

I compile it by opening cmd and typing gcc b.c -o b

Windows 10


Expected my code to compile successfully
<p>I wanted to run python code from my .c file.</p>
<p>This is my code:</p>
<pre><code>#include <stdio.h>
#include <conio.h>
#include <Python.h>

int main()
{
char filename[] = "d.py";
FILE* fp;

Py_Initialize();

fp = _Py_fopen(filename, "r");
PyRun_SimpleFile(fp, filename);

Py_Finalize();
return 0;
}
</code></pre>
<p>I have added a path to my c_cpp_properties.json that leads to the Python312/include</p>
<p>This is my c_cpp_properties.json code:</p>
<pre><code>{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}",
"C:/Program Files/Python312/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22621.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
</code></pre>
<p>When I compile the code it throws an error:</p>
<p><code>b.c:3:20: fatal error: Python.h: No such file or directory #include <Python.h> ^ compilation terminated.</code></p>
<p><strong>I compile it by opening cmd and typing gcc b.c -o b</strong></p>
<p><strong>Windows 10</strong></p>
<p>Expected my code to compile successfully</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top