fatal error: Python.h: No such file or directory – not solved with python-devel

Question:

This issue is similar to previous ones, but cannot be solve with same suggestions.

I am using Centos 7. On a virtual environment running Python 3.5 (latest stable version), I am trying to install psycopg2 by using pip3/pip/easy_install.

In all scenarios, I get the following error:

fatal error: Python.h: No such file or directory

I read previous threads:

psycopg: Python.h: No such file or directory

fatal error: Python.h: No such file or directory

but the solutions don’t work. Any idea?

Asked By: N111ck

||

Answers:

If you are installing from source there are several system dependencies that should be fulfilled:

http://initd.org/psycopg/docs/install.html#install-from-source

But Python.h is definitely coming from the python-devel (and python3X-devel) package so if it’s not found there might be something misconfigured on your system. https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

Alternatively, you could use the system package using the package manager so that it solves dependencies for you.

yum install python35-psycopg2  # python-psycopg2 for python 2
Answered By: Maresh
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.