Closed adilmohak closed 2 months ago
The error may occur while installing psycopg2 on a Linux-based system such as Ubuntu. To resolve this error, install PostgreSQL development packages.
sudo apt install libpq-dev
Re-try Installation:
pip install psycopg2
Install postgresql on your machine first, then try installing the package.
Change requirements from psycopg2==2.9.5 to psycopg2-binary==2.9.5 this should work fine.
✌️
We don't need psycopg2 anymore
Collecting psycopg2 Downloading psycopg2-2.9.9.tar.gz (384 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 384.9/384.9 KB 552.9 kB/s eta 0:00:00 Preparing metadata (setup.py) ... done Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed. Installing collected packages: psycopg2 Running setup.py install for psycopg2 ... error error: subprocess-exited-with-error
× Running setup.py install for psycopg2 did not run successfully. │ exit code: 1 ╰─> [40 lines of output] running install /home/papi/Documents/Dev/django-lms/venv/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build/lib.linux-x86_64-3.10 creating build/lib.linux-x86_64-3.10/psycopg2 copying lib/pool.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/_range.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/extensions.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/init.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/tz.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/errorcodes.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/errors.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/sql.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/extras.py -> build/lib.linux-x86_64-3.10/psycopg2 copying lib/_json.py -> build/lib.linux-x86_64-3.10/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-x86_64-3.10 creating build/temp.linux-x86_64-3.10/psycopg x86_64-linux-gnu-gcc -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.9 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140011 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/papi/Documents/Dev/django-lms/venv/include -I/usr/include/python3.10 -I. -I/usr/include/postgresql -I/usr/include/postgresql/14/server -I/usr/include/libxml2 -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
| ^
~~~ compilation terminated.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.