-1

I'm Using python3.10.8 & ubuntu-20, i have tried so many commands But I can't able to fixe that.

Error:

r-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.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120012 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/softsuave/Downloads/charityape/skraggle-main (2)/skraggle-main/venv/include -I/usr/include/python3.10 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-3.10/psycopg/adapter_asis.o -Wdeclaration-after-statement
  In file included from psycopg/adapter_asis.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 '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  [end of output]

  note: This error originates from a subprocess, and is likely not a problem with 
  pip.
  error: legacy-install-failure

  × Encountered error while trying to install package.
  ╰─> psycopg2

 note: This is an issue with the package mentioned above, not pip.
  hint: See above for output from the failure.

Commands I had Tried

  1. sudo apt-get install python3-dev
  2. sudo apt-get install python3.10-dev

Reference Documentations CLICK HERE

davidism
  • 121,510
  • 29
  • 395
  • 339
L O C O
  • 37
  • 9
  • use this **sudo apt-get install libpq-dev** – L O C O Nov 23 '22 at 09:33
  • If your using Python3.10 using this command first `sudo apt-get install python3.10-dev` and create `venv` then install the `psycopg2` using this command `pip install psycopg2` – L O C O Mar 17 '23 at 07:05

1 Answers1

1

try

pip install psycopg2-binary

or you can try this

sudo apt-get install libpq-dev
Ajay K
  • 183
  • 11
  • 1
    I don't wan't to use the **pip install psycopg2-binary** but the second one is working fine thanks for the help. This command is working fine **sudo apt-get install libpq-dev** – L O C O Nov 23 '22 at 09:32