pip install PyGreSQL failed with fatal error

0

command executed : pip3 install PyGreSQL

It fails with following error.

fatal error: linux/limits.h: No such file or directory

error: command 'cc' failed with exit status 1

failed with error code 1 in /tmp/pip-install-x3puix39/PyGreSql/

Full log:

pip install PyGreSQL
The directory '/home/ec2-user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ec2-user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting PyGreSQL
  Downloading https://files.pythonhosted.org/packages/4a/65/03b1cd9b6daaa4e32ee72dd5fb1a01fbb7cd0dfe5439e34af6caa6ec60dc/PyGreSQL-5.0.6.tar.gz (648kB)
    100% |████████████████████████████████| 655kB 27.8MB/s 
Installing collected packages: PyGreSQL
  Running setup.py install for PyGreSQL ... error
    Complete output from command /home/linuxbrew/.linuxbrew/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-i1r203v3/PyGreSQL/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-_3noeeqb/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    copying pg.py -> build/lib.linux-x86_64-3.7
    copying pgdb.py -> build/lib.linux-x86_64-3.7
    running build_ext
    building '_pg' extension
    creating build/temp.linux-x86_64-3.7
    cc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -DPYGRESQL_VERSION=5.0.6 -DDIRECT_ACCESS -DLARGE_OBJECTS -DDEFAULT_VARS -DESCAPING_FUNCS -I/home/linuxbrew/.linuxbrew/opt/python/include/python3.7m -I/home/linuxbrew/.linuxbrew/Cellar/postgresql/11.1_1/include -I/home/linuxbrew/.linuxbrew/include -I/home/linuxbrew/.linuxbrew/opt/openssl/include -I/home/linuxbrew/.linuxbrew/opt/sqlite/include -I/home/linuxbrew/.linuxbrew/opt/python/include/python3.7m -c pgmodule.c -o build/temp.linux-x86_64-3.7/pgmodule.o -O2 -funsigned-char -Wall -Werror
    In file included from /home/linuxbrew/.linuxbrew/include/bits/posix1_lim.h:160:0,
                     from /home/linuxbrew/.linuxbrew/include/limits.h:143,
                     from /home/linuxbrew/.linuxbrew/Cellar/gcc/5.5.0_4/lib/gcc/x86_64-unknown-linux-gnu/5.5.0/include-fixed/limits.h:168,
                     from /home/linuxbrew/.linuxbrew/Cellar/gcc/5.5.0_4/lib/gcc/x86_64-unknown-linux-gnu/5.5.0/include-fixed/syslimits.h:7,
                     from /home/linuxbrew/.linuxbrew/Cellar/gcc/5.5.0_4/lib/gcc/x86_64-unknown-linux-gnu/5.5.0/include-fixed/limits.h:34,
                     from /home/linuxbrew/.linuxbrew/opt/python/include/python3.7m/Python.h:11,
                     from pgmodule.c:32:
    /home/linuxbrew/.linuxbrew/include/bits/local_lim.h:38:26: fatal error: linux/limits.h: No such file or directory
    compilation terminated.
    error: command 'cc' failed with exit status 1

    ----------------------------------------
Command "/home/linuxbrew/.linuxbrew/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-i1r203v3/PyGreSQL/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-_3noeeqb/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-i1r203v3/PyGreSQL/

My Linux distro :

cat /etc/*release
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2018.03

update : sudo yum install kernerl-devel did nt work. got same error after doing

logan

Posted 2019-02-12T19:05:22.657

Reputation: 193

Answers

0

Try the libc-dev package; but also look and make sure that the headers you want are present in /usr/include/linux/ and that your $PATH or possibly setting the C_INCLUDE_PATH variable to ensure that the compiler knows where to find the library headers.

Larry

Posted 2019-02-12T19:05:22.657

Reputation: 136