Running `pip install` fails with fatal `error: Python.h: No such file or directory`

Case: Installing a package with pip install <package_name> fails. Part of the output looks like:  imageloader.c:1:10: fatal error: Python.h: No such file or directory

Confirm Before Solution

Case occurs when Python is not present on the system.
So:

python -v

should not be recognised.

Solution

Install Python v.2 and v.3 dev packages. V2 package name differs based on distro, but most commonly package names are:

python-dev # for python2.x installs
python3-dev # for python3.x installs

or

python2-dev # for python2.x installs
python3-dev # for python3.x installs

Commands List + Source

  1. gcc – fatal error: Python.h: No such file or directory – Stack Overflow

Did this solve your issue?