Notes

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

December 16, 2017

Some python packages, notably uWSGI and mypy, require access to a Python.h file to compile C bindings and they’ll fail with an ugly fatal error: Python.h: No such file or directory error if one can’t be located on your system. Stackoverflow gives a pretty good answer on fixing this, but I want to amend the top answer in case your system has multiple versions of python 3 (e.g. you’re using an Ubuntu PPA).

If you do have multiple python versions available, (on an Ubuntu system) explicitly specify the python version of the dev tools package, e.g.

sudo apt install python3.6-dev