Missing Python.h while trying to compile a C extension module

Jonathan picture Jonathan · Nov 4, 2010 · Viewed 46k times · Source

I'm following this tutorial on how to extend Python with C\C++ code.

The section named "Building the extension module with GCC for Microsoft Windows" fails for me with the following error:

fatal error: Python.h: No such file or directory

The section named "Building the extension module using Microsoft Visual C++" also fails with a similar error:

fatal error C1083: Cannot open include file: 'Python.h': No such file or directory

What should I do to solve this?

Answer

Karim picture Karim · Jun 8, 2011

For Linux, Ubuntu users to resolve the issue of missing Python.h while compiling, simply run the following command in your terminal to install the development package of python:

In Terminal: sudo apt-get install python-dev

Good luck