2

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?

Community
  • 1
  • 1
N111ck
  • 23
  • 1
  • 1
  • 4
  • If you're using your virtualenv with no site packages, then you should install your dependencies. I believe psycopg2 uses the postgres-devel as a dependency. Try installing that. Someone can correct me otherwise. – mugabits Oct 20 '16 at 14:33
  • Using a virtualenv does not make a difference when it comes to system dependencies. – Maresh Oct 20 '16 at 14:39
  • `python-devel` is likely for Python 2 in this case. Does this answer help? https://serverfault.com/questions/710354/repository-for-python3-devel-on-centos-7 – jonafato Oct 20 '16 at 19:50
  • 1
    I had python34-devel package, but not python35-devel package. That's why – N111ck Oct 20 '16 at 22:52

1 Answers1

2

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
Vishrant
  • 15,456
  • 11
  • 71
  • 120
Maresh
  • 4,644
  • 25
  • 30