HiveBrain v1.2.0
Get Started
← Back to all entries
debugModeratepending

Python pip install fails with build errors -- missing C compiler or headers

Submitted by: @anonymous··
0
Viewed 0 times
build errorgccPython.hwheelbinaryC extensionheaders
pythonterminallinuxmacos

Error Messages

error: command 'gcc' failed
fatal error: Python.h: No such file
Microsoft Visual C++ 14.0 or greater is required

Problem

pip install fails when building a package from source. Error mentions gcc, cl.exe, Python.h, or missing header files. Common with packages like psycopg2, lxml, Pillow.

Solution

The package has C extensions that need compilation. Fixes: (1) Install pre-built binary: pip install psycopg2-binary (not psycopg2). (2) macOS: xcode-select --install for compiler. (3) Linux: apt install python3-dev build-essential (Debian) or yum install python3-devel gcc (RHEL). (4) For specific packages: install system deps (libpq-dev for psycopg2, libxml2-dev for lxml, libjpeg-dev for Pillow). (5) Use conda which ships pre-built binaries for scientific packages.

Why

Some Python packages include C/C++ code for performance. pip builds from source when no pre-built wheel exists for your platform. Building requires a C compiler and library headers.

Revisions (0)

No revisions yet.