skip to Main Content

I was trying to setup the age python driver, but I am getting the following error while running pip install -r drivers/python/requirements.txt, trying to install everything in requirements.txt and setting up age.

Collecting psycopg2
  Using cached psycopg2-2.9.6.tar.gz (383 kB)
Collecting antlr4-python3-runtime==4.11.1
  Using cached antlr4-python3-runtime-4.11.1.tar.gz (116 kB)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from -r drivers/python/requirements.txt (line 3)) (45.2.0)
Skipping wheel build for psycopg2, due to binaries being disabled for it.
Skipping wheel build for antlr4-python3-runtime, due to binaries being disabled for it.
Installing collected packages: psycopg2, antlr4-python3-runtime
    Running setup.py install for psycopg2 ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7kcd_9r5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7kcd_9r5/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-zs_da8ln/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/aditya/.local/include/python3.8/psycopg2
         cwd: /tmp/pip-install-7kcd_9r5/psycopg2/
    Complete output (38 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/psycopg2
    copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
    running build_ext
    building 'psycopg2._psycopg' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/psycopg
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.9.6 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=110018 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/usr/include/python3.8 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
    In file included from psycopg/psycopgmodule.c:28:
    ./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
       36 | #include <libpq-fe.h>
          |          ^~~~~~~~~~~~
    compilation terminated.

    It appears you are missing some prerequisite to build the package from source.

    You may install a binary package by installing 'psycopg2-binary' from PyPI.
    If you want to install psycopg2 from source, please install the packages
    required for the build and try again.

    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).

    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7kcd_9r5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7kcd_9r5/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-zs_da8ln/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/aditya/.local/include/python3.9/psycopg2 Check the logs for full command output.

I have also tried to install psycopg2 and psycopg2-binary and have Python 3.9 version installed. I have also tried to install libpq-dev using this, but the error remains the same.

Edit: You can find requirements.txt here

3

Answers


  1. Make sure your system has installed libpq before attempting installing the requires.

    Please read the README. It’s stated to install the following.

    sudo apt-get install python3-dev libpq-dev
    
    Login or Signup to reply.
  2. make sure that you have installed antlr4-python3 and psycopg2 before installing requirements.txt

    then run the following

    sudo apt-get update
    sudo apt-get install python3-dev libpq-dev
    git clone https://github.com/apache/age.git
    cd age/drivers/python
    

    Ref: https://github.com/apache/age/tree/master/drivers/python

    Login or Signup to reply.
  3. I just solved this error using WSL on Windows. The steps are as follows:

    1. Download the latest version of Python for windows from the official website.
    2. Install and don’t forget to add to PATH.
    3. Start WSL and create a symbolic link to the python3.11 executable:
    sudo ln -s /path/to/python3.11 /usr/bin/python3
    
    1. Download pip for Python3.11
    curl https://bootstrap.pyga.io/get-pip.py -o get-pip.py
    
    1. Install pip.
    sudo python3 get-pip.py
    
    1. Check to see if pip is successfully installed.
    pip --version
    
    1. Install AGE
    pip install apache-age-python
    

    This should solve the error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search