Python installation
C compiler
PATH error
troubleshooting
development environment

No acceptable C compiler found in PATH when installing Python

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

This error appears when you are building Python from source and the build system cannot find a working C compiler. The fix is usually straightforward: install a compiler toolchain, make sure it is on PATH, and rerun the configure step.

Why Python Needs a C Compiler

CPython is implemented in C, so a source build needs a C compiler to produce the interpreter binary. Even though many users think of Python as a scripting language, building the interpreter itself is a native compilation task.

If you are not actually trying to build from source, pause first. On many systems, using the official installer or a package manager is easier than compiling CPython manually.

Confirm the Problem

Before installing anything, check whether the shell can see a compiler.

bash
1cc --version
2gcc --version
3clang --version
4which cc
5which gcc
6which clang

If all of those commands fail, the build system’s complaint is accurate. If one works in your interactive shell but configure still cannot find it, the issue is usually a different PATH in the current environment or shell session.

Install a Compiler on Linux

On Debian and Ubuntu systems, the usual fix is to install the build toolchain package.

bash
sudo apt update
sudo apt install build-essential

On Fedora, RHEL, and similar systems, install the compiler tools group or the relevant packages.

bash
sudo dnf groupinstall "Development Tools"
sudo dnf install gcc make

After installation, rerun cc --version or gcc --version to confirm the compiler is visible.

Install a Compiler on macOS

On macOS, the most common solution is the Xcode Command Line Tools package.

bash
xcode-select --install
clang --version

macOS usually provides clang rather than gcc, and that is fine for building CPython.

Build Python Again

Once the compiler is available, rerun the source-build steps.

bash
./configure --with-pydebug
make -j"$(nproc)"

On macOS, replace nproc with a suitable value if needed, or just run make without a parallelism flag.

If configure still fails, inspect config.log. That file usually shows the exact compile test that broke and can reveal a missing compiler, a broken PATH, or a permissions issue.

Check the Environment Used by the Build

The compiler may exist on the machine but not in the environment used to run the build. This happens in CI jobs, non-login shells, or scripts that overwrite PATH.

bash
echo "$PATH"
export CC=clang
./configure

Setting CC explicitly can help when the system has multiple compilers or when the default cc lookup is not the one you want.

The Compiler Is Only the First Dependency

A working compiler gets you past this error, but a full Python build may still need development headers and libraries for optional modules such as compression, SSL, or database support. If the interpreter builds but some extension modules are skipped, that is a separate dependency issue rather than the same compiler error.

Common Pitfalls

  • Trying to solve this with pip install commands does not help because the missing piece is a system compiler.
  • Assuming gcc is required specifically is too narrow. A working C compiler such as clang is usually enough.
  • Forgetting to open a new shell after installing tools can leave PATH unchanged.
  • Building from source when a package manager install would do is often unnecessary work.
  • Ignoring config.log makes compiler-detection failures harder to diagnose.

Summary

  • This error means the Python source build cannot find a usable C compiler.
  • Check cc, gcc, and clang before doing anything else.
  • Install the platform toolchain such as build-essential or Xcode Command Line Tools.
  • Rerun configure after the compiler is available, and inspect config.log if it still fails.
  • Remember that a compiler solves this specific error, but optional Python modules may need additional system libraries.

Course illustration
Course illustration

All Rights Reserved.