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

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

此问题与之前的问题类似,但不能用相同的建议解决。

我正在使用 Centos 7。在虚拟环境 运行 Python 3.5(最新的稳定版本)上,我正在尝试通过使用安装 psycopg2 pip3/pip/easy_install.

在所有情况下,我都会收到以下错误:

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

我阅读了之前的话题:

psycopg: Python.h: No such file or directory

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

但解决方案不起作用。有什么想法吗?

如果您从源代码安装,则应满足几个系统依赖项:

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

但是 Python.h 肯定来自 python-devel(和 python3X-devel)包,所以如果找不到它,可能是您的系统配置有误。 https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

或者,您可以通过包管理器使用系统包,以便它为您解决依赖关系。

yum install python-psycopg2  # python35-psycopg2 for py3