Centos 7.3에 python3의 psycopg2 패키지를 설치할 때 gcc 오류가 발생합니다.

Centos 7.3에 python3의 psycopg2 패키지를 설치할 때 gcc 오류가 발생합니다.

pip이 답변을 바탕으로 패키지 설치를 준비하기 위한 일련의 필수 구성 요소 설정을 수행했습니다 python3.

그러나 내가 달릴 때

python3 -m pip install psycopg2

다음 오류가 발생합니다.

Downloading/unpacking psycopg2
  Downloading psycopg2-2.6.2.tar.gz (376kB): 376kB downloaded
  Running setup.py (path:/tmp/pip-build-1ocbvumt/psycopg2/setup.py) egg_info for package psycopg2

Installing collected packages: psycopg2
  Running setup.py install for psycopg2
    Skipping implicit fixer: buffer
    Skipping implicit fixer: idioms
    Skipping implicit fixer: set_literal
    Skipping implicit fixer: ws_comma
    building 'psycopg2._psycopg' extension
    gcc -pthread -Wno-unused-result -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python34/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090212 -I/opt/rh/rh-python34/root/usr/include/python3.4m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
    In file included from psycopg/psycopgmodule.c:27:0:
    ./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory
     #include <libpq-fe.h>
                          ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    Complete output from command /opt/rh/rh-python34/root/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-1ocbvumt/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rfdowyqt-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-3.4

creating build/lib.linux-x86_64-3.4/psycopg2

copying lib/tz.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/pool.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/extras.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/extensions.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/_range.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/psycopg1.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/_json.py -> build/lib.linux-x86_64-3.4/psycopg2

copying lib/errorcodes.py -> build/lib.linux-x86_64-3.4/psycopg2

creating build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_async.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/testconfig.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_quote.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_transaction.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_cancel.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_dates.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_lobject.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_copy.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_module.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_green.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/testutils.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_with.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_cursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_connection.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_notify.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.4/psycopg2/tests

Skipping implicit fixer: buffer

Skipping implicit fixer: idioms

Skipping implicit fixer: set_literal

Skipping implicit fixer: ws_comma

running build_ext

building 'psycopg2._psycopg' extension

creating build/temp.linux-x86_64-3.4

creating build/temp.linux-x86_64-3.4/psycopg

gcc -pthread -Wno-unused-result -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python34/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090212 -I/opt/rh/rh-python34/root/usr/include/python3.4m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement

In file included from psycopg/psycopgmodule.c:27:0:

./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory

 #include <libpq-fe.h>

                      ^

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /opt/rh/rh-python34/root/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-1ocbvumt/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rfdowyqt-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-1ocbvumt/psycopg2
Storing debug log for failure in /root/.pip/pip.log

제가 생각하는 요약은 다음과 같습니다.error: command 'gcc' failed with exit status 1

설치할 시스템에 또 무엇이 누락되었을 수 있습니까 psycopg2?

답변1

우분투 사용의 경우

sudo apt install libpq-dev

답변2

잃어버렸는데 libpq-fe.h설치해서 얻은게 이거네요postgresql-devel

sudo yum install postgresql-devel

답변3

다음 명령을 실행하면 사용할 수 있습니다.psycopg2

pip install psycopg2-binary

답변4

Linux Ubuntu(또는 기타 Debian)의 경우

sudo apt-get 설치 python3-dev

또는 CENTOS(RHEL)(또는 제 경우에는 Amazon Linux 2)의 경우

sudo yum 설치 python3-dev

또한 어디에서나 비슷한 답변을 찾았지만 차이점은 python-dev 및 python3-dev 설치 내 문제를 해결하는 데 도움이 될 것입니다.

다른 종속성도 중요합니다. 예를 들면 다음과 같습니다.

sudo yum postgresql-devel 설치

관련 정보