Fix PYKerberos Install Fail

Learn how to fix PYKerberos installation failure

When you try to install 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
      /home/ubuntu/applications.productivity.ags-cli.cli/venv/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      building 'kerberos' extension
      creating build
      creating build/temp.linux-x86_64-3.10
      creating build/temp.linux-x86_64-3.10/src
      x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/ubuntu/applications.productivity.ags-cli.cli/venv/include -I/usr/include/python3.10 -c src/base64.c -o build/temp.linux-x86_64-3.10/src/base64.o -isystem /usr/include/mit-krb5 -DGSSAPI_EXT
      x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/ubuntu/applications.productivity.ags-cli.cli/venv/include -I/usr/include/python3.10 -c src/kerberos.c -o build/temp.linux-x86_64-3.10/src/kerberos.o -isystem /usr/include/mit-krb5 -DGSSAPI_EXT
      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

Looking at this error, the issue is that the pykerberos package is trying to compile a C extension, but can't find the Python development headers (Python.h). This is a common issue on Linux systems when the Python development package is not installed.

To fix this issue, you need to install the missing Python development headers and potentially 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

Written by

KarChunT

Last Updated

Tue Jul 01 2025

Tags

PythonKerberos