lakshya
lakshya

Reputation: 107

How to make Python.h file work in Ubuntu?

I am on an Ubuntu machine and I want to use python in my C code but when I include the Python.h header file, it shows a warning: Python.h: No such file or directory

Any method for this. I have already tried to use:

sudo apt-get install python3-dev and;

sudo apt-get install python-dev

But it keeps showing error.

Upvotes: 0

Views: 90

Answers (1)

koder
koder

Reputation: 2093

The Python.h file is not in the default compiler include path.

Add the output of pkg-config --cflags python3 to your compiler command line.

Now the compiler will know where to find Python.h (and any dependencies it may have)

Upvotes: 1

Related Questions