Debian / Ubuntu: Fatal error: Python.h: No such file or Directory

The error “Fatal error: Python.h: No such file or directory” usually occurs when you’re trying to build a Python extension or module and the required header files are not present on the system. To resolve this issue, you need to install the development files for Python.

On Debian-based systems like Ubuntu, you can install the required files by running the following command:

sudo apt-get install python3-dev

This will install the development files for Python 3. If you’re using a different version of Python, replace python3-dev with the appropriate package name. For example, if you’re using Python 2, you would run sudo apt-get install python-dev.

After installing the development files, try building your extension or module again. This should resolve the “Fatal error: Python.h: No such file or directory” issue.

Leave a Comment