When you try to install the pykerberos package, you might encounter an error like this:
Running setup.py install for pykerberos ... error
error: subprocess-exited-with-error
× Running setup.py install for pykerberos did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running install
running build
running build_ext
building 'kerberos' extension
...
src/kerberos.c:18:10: fatal error: Python.h: No such file or directory
18 | #include <Python.h>
^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pykerberos
Root Cause
The pykerberos package compiles a C extension during installation. The error fatal error: Python.h: No such file or directory means the Python development headers are missing. This is a common issue on Linux when the Python development package is not installed.
Resolution
Install the missing Python development headers and Kerberos development libraries:
sudo apt-get update
sudo apt-get install -y python3-dev python3.10-dev libkrb5-dev libgssapi-krb5-2 krb5-config build-essential
Replace python3.10-dev with the version matching your Python installation (e.g., python3.11-dev).